Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layer-browser: Static scenegraph example #3129

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/layer-browser/src/app.js
Expand Up @@ -303,6 +303,7 @@ export default class App extends PureComponent {
onViewStateChange={this._onViewStateChange}
effects={effects ? this._effects : []}
pickingRadius={pickingRadius}
onWebGLInitialized={gl => {window.gl = gl;}}
onHover={this._onHover}
onClick={this._onClick}
useDevicePixels={useDevicePixels}
Expand Down
44 changes: 41 additions & 3 deletions examples/layer-browser/src/examples/additional-layers.js
Expand Up @@ -12,7 +12,7 @@ import {
import {_GPUGridLayer as GPUGridLayer} from '@deck.gl/aggregation-layers';
import * as h3 from 'h3-js';

import {registerLoaders} from '@loaders.gl/core';
import {registerLoaders, parse} from '@loaders.gl/core';
import {PLYLoader} from '@loaders.gl/ply';
import {GLTFScenegraphLoader} from '@luma.gl/addons';

Expand Down Expand Up @@ -51,13 +51,50 @@ const SimpleMeshLayerExample = {
}
};

const ScenegraphLayerExample = {
const ScenegraphLayerStaticExample = {
layer: ScenegraphLayer,
props: {
id: 'scenegraph-layer',
data: dataSamples.points,
pickable: true,
sizeScale: 50,
scenegraph: null,
getPosition: d => d.COORDINATES,
getOrientation: d => [Math.random() * 360, Math.random() * 360, Math.random() * 360],
getTranslation: d => [0, 0, Math.random() * 10000],
getScale: [1, 1, 1]
}
};

const DUCK_URL =
'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Binary/Duck.glb';
/* global fetch, window */
fetch(DUCK_URL)
.then(response => response.arrayBuffer())
.then(arrayBuffer => {
const loadOptions = {
gl: window.gl,
waitForFullLoad: true,
modelOptions: {
vs: require('../../../../modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-vertex.glsl.js').default,
fs: require('../../../../modules/mesh-layers/src/scenegraph-layer/scenegraph-layer-fragment.glsl.js').default,
modules: ['project32', 'picking'],
isInstanced: true
}
};
return parse(arrayBuffer, GLTFScenegraphLoader, loadOptions);
})
.then(data => {
ScenegraphLayerStaticExample.props.scenegraph = data.scenes[0];
});

const ScenegraphLayerExample = {
layer: ScenegraphLayer,
props: {
id: 'scenegraph-layer-static',
data: dataSamples.points,
pickable: true,
sizeScale: 50,
scenegraph:
'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Binary/Duck.glb',
getPosition: d => d.COORDINATES,
Expand Down Expand Up @@ -176,7 +213,8 @@ const TripsLayerExample = {
export default {
'Mesh Layers': {
SimpleMeshLayer: SimpleMeshLayerExample,
ScenegraphLayer: ScenegraphLayerExample
'ScenegraphLayer (URL scenegraph)': ScenegraphLayerExample,
'ScenegraphLayer (Static scenegraph)': ScenegraphLayerStaticExample
},
'Geo Layers': {
S2Layer: S2LayerExample,
Expand Down