@luma.gl/engine 9.0.0-beta.4 → 9.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/key-frames.js +54 -54
- package/dist/animation/timeline.d.ts.map +1 -1
- package/dist/animation/timeline.js +95 -100
- package/dist/animation-loop/animation-loop-template.d.ts +1 -1
- package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop-template.js +19 -5
- package/dist/animation-loop/animation-loop.d.ts +2 -2
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +433 -356
- package/dist/animation-loop/animation-props.d.ts +2 -2
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js +0 -1
- package/dist/animation-loop/make-animation-loop.d.ts +2 -2
- package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/make-animation-loop.js +28 -24
- package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
- package/dist/debug/copy-texture-to-image.js +41 -42
- package/dist/debug/debug-framebuffer.d.ts.map +1 -1
- package/dist/debug/debug-framebuffer.js +43 -40
- package/dist/debug/debug-shader-layout.js +24 -25
- package/dist/debug/pixel-data-utils.d.ts.map +1 -1
- package/dist/debug/pixel-data-utils.js +34 -36
- package/dist/dist.dev.js +3873 -8643
- package/dist/geometries/cone-geometry.d.ts +1 -1
- package/dist/geometries/cone-geometry.d.ts.map +1 -1
- package/dist/geometries/cone-geometry.js +11 -17
- package/dist/geometries/cube-geometry.d.ts +1 -1
- package/dist/geometries/cube-geometry.d.ts.map +1 -1
- package/dist/geometries/cube-geometry.js +190 -61
- package/dist/geometries/cylinder-geometry.d.ts +1 -1
- package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
- package/dist/geometries/cylinder-geometry.js +9 -14
- package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
- package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/ico-sphere-geometry.js +141 -160
- package/dist/geometries/plane-geometry.d.ts +1 -1
- package/dist/geometries/plane-geometry.d.ts.map +1 -1
- package/dist/geometries/plane-geometry.js +92 -110
- package/dist/geometries/sphere-geometry.d.ts +1 -1
- package/dist/geometries/sphere-geometry.d.ts.map +1 -1
- package/dist/geometries/sphere-geometry.js +76 -95
- package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +99 -117
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-table.js +3 -1
- package/dist/geometry/geometry-utils.js +35 -32
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +80 -71
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +80 -99
- package/dist/geometry/gpu-table.js +41 -1
- package/dist/index.cjs +241 -206
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +41 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/clip-space.d.ts +1 -1
- package/dist/lib/clip-space.d.ts.map +1 -1
- package/dist/lib/clip-space.js +23 -28
- package/dist/lib/pipeline-factory.d.ts +1 -5
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +64 -68
- package/dist/lib/shader-factory.d.ts +17 -0
- package/dist/lib/shader-factory.d.ts.map +1 -0
- package/dist/lib/shader-factory.js +44 -0
- package/dist/model/model.d.ts +22 -10
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +562 -410
- package/dist/scenegraph/group-node.d.ts +1 -1
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +73 -83
- package/dist/scenegraph/model-node.d.ts +2 -2
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +31 -24
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +136 -124
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/shader-inputs.js +99 -58
- package/dist/transform/buffer-transform.d.ts +1 -1
- package/dist/transform/buffer-transform.d.ts.map +1 -1
- package/dist/transform/buffer-transform.js +65 -57
- package/dist/transform/texture-transform.d.ts +1 -1
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +109 -114
- package/dist.min.js +2 -272
- package/package.json +10 -9
- package/src/animation/timeline.ts +20 -20
- package/src/animation-loop/animation-loop-template.ts +10 -8
- package/src/animation-loop/animation-loop.ts +20 -10
- package/src/animation-loop/animation-props.ts +1 -1
- package/src/animation-loop/make-animation-loop.ts +17 -8
- package/src/debug/copy-texture-to-image.ts +8 -6
- package/src/debug/debug-framebuffer.ts +16 -3
- package/src/debug/debug-shader-layout.ts +1 -1
- package/src/debug/pixel-data-utils.ts +3 -6
- package/src/geometries/cube-geometry.ts +17 -13
- package/src/geometries/ico-sphere-geometry.ts +1 -1
- package/src/geometries/plane-geometry.ts +1 -1
- package/src/geometries/sphere-geometry.ts +1 -1
- package/src/geometries/truncated-cone-geometry.ts +2 -1
- package/src/geometry/geometry-table.ts +9 -6
- package/src/geometry/geometry-utils.ts +1 -1
- package/src/geometry/geometry.ts +9 -6
- package/src/geometry/gpu-geometry.ts +14 -6
- package/src/index.ts +1 -0
- package/src/lib/clip-space.ts +14 -18
- package/src/lib/pipeline-factory.ts +12 -22
- package/src/lib/shader-factory.ts +55 -0
- package/src/model/model.ts +74 -42
- package/src/scenegraph/group-node.ts +14 -10
- package/src/scenegraph/model-node.ts +2 -2
- package/src/scenegraph/scenegraph-node.ts +2 -2
- package/src/shader-inputs.ts +19 -12
- package/src/transform/buffer-transform.ts +16 -8
- package/src/transform/texture-transform.ts +14 -15
- package/dist/animation/key-frames.js.map +0 -1
- package/dist/animation/timeline.js.map +0 -1
- package/dist/animation-loop/animation-loop-template.js.map +0 -1
- package/dist/animation-loop/animation-loop.js.map +0 -1
- package/dist/animation-loop/animation-props.js.map +0 -1
- package/dist/animation-loop/make-animation-loop.js.map +0 -1
- package/dist/debug/copy-texture-to-image.js.map +0 -1
- package/dist/debug/debug-framebuffer.js.map +0 -1
- package/dist/debug/debug-shader-layout.js.map +0 -1
- package/dist/debug/pixel-data-utils.js.map +0 -1
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/dist/geometry/geometry-table.js.map +0 -1
- package/dist/geometry/geometry-utils.js.map +0 -1
- package/dist/geometry/geometry.js.map +0 -1
- package/dist/geometry/gpu-geometry.js.map +0 -1
- package/dist/geometry/gpu-table.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/clip-space.js.map +0 -1
- package/dist/lib/pipeline-factory.js.map +0 -1
- package/dist/model/model.js.map +0 -1
- package/dist/scenegraph/group-node.js.map +0 -1
- package/dist/scenegraph/model-node.js.map +0 -1
- package/dist/scenegraph/scenegraph-node.js.map +0 -1
- package/dist/shader-inputs.js.map +0 -1
- package/dist/transform/buffer-transform.js.map +0 -1
- package/dist/transform/texture-transform.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -22,9 +22,9 @@ var __publicField = (obj, key, value) => {
|
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
var
|
|
27
|
-
__export(
|
|
25
|
+
// dist/index.js
|
|
26
|
+
var dist_exports = {};
|
|
27
|
+
__export(dist_exports, {
|
|
28
28
|
AnimationLoop: () => AnimationLoop,
|
|
29
29
|
AnimationLoopTemplate: () => AnimationLoopTemplate,
|
|
30
30
|
BufferTransform: () => BufferTransform,
|
|
@@ -42,6 +42,7 @@ __export(src_exports, {
|
|
|
42
42
|
PipelineFactory: () => PipelineFactory,
|
|
43
43
|
PlaneGeometry: () => PlaneGeometry,
|
|
44
44
|
ScenegraphNode: () => ScenegraphNode,
|
|
45
|
+
ShaderFactory: () => ShaderFactory,
|
|
45
46
|
SphereGeometry: () => SphereGeometry,
|
|
46
47
|
TextureTransform: () => TextureTransform,
|
|
47
48
|
Timeline: () => Timeline,
|
|
@@ -49,9 +50,9 @@ __export(src_exports, {
|
|
|
49
50
|
_ShaderInputs: () => ShaderInputs,
|
|
50
51
|
makeAnimationLoop: () => makeAnimationLoop
|
|
51
52
|
});
|
|
52
|
-
module.exports = __toCommonJS(
|
|
53
|
+
module.exports = __toCommonJS(dist_exports);
|
|
53
54
|
|
|
54
|
-
//
|
|
55
|
+
// dist/animation/timeline.js
|
|
55
56
|
var channelHandles = 1;
|
|
56
57
|
var animationHandles = 1;
|
|
57
58
|
var Timeline = class {
|
|
@@ -156,7 +157,7 @@ var Timeline = class {
|
|
|
156
157
|
}
|
|
157
158
|
};
|
|
158
159
|
|
|
159
|
-
//
|
|
160
|
+
// dist/animation/key-frames.js
|
|
160
161
|
var KeyFrames = class {
|
|
161
162
|
startIndex = -1;
|
|
162
163
|
endIndex = -1;
|
|
@@ -213,7 +214,7 @@ var KeyFrames = class {
|
|
|
213
214
|
}
|
|
214
215
|
};
|
|
215
216
|
|
|
216
|
-
//
|
|
217
|
+
// dist/animation-loop/animation-loop-template.js
|
|
217
218
|
var AnimationLoopTemplate = class {
|
|
218
219
|
constructor(animationProps) {
|
|
219
220
|
}
|
|
@@ -222,7 +223,7 @@ var AnimationLoopTemplate = class {
|
|
|
222
223
|
}
|
|
223
224
|
};
|
|
224
225
|
|
|
225
|
-
//
|
|
226
|
+
// dist/animation-loop/animation-loop.js
|
|
226
227
|
var import_core = require("@luma.gl/core");
|
|
227
228
|
var import_core2 = require("@luma.gl/core");
|
|
228
229
|
var import_stats = require("@probe.gl/stats");
|
|
@@ -564,7 +565,14 @@ var AnimationLoop = class {
|
|
|
564
565
|
/** Default viewport setup */
|
|
565
566
|
_resizeViewport() {
|
|
566
567
|
if (this.props.autoResizeViewport && this.device.gl) {
|
|
567
|
-
this.device.gl.viewport(
|
|
568
|
+
this.device.gl.viewport(
|
|
569
|
+
0,
|
|
570
|
+
0,
|
|
571
|
+
// @ts-expect-error Expose canvasContext
|
|
572
|
+
this.device.gl.drawingBufferWidth,
|
|
573
|
+
// @ts-expect-error Expose canvasContext
|
|
574
|
+
this.device.gl.drawingBufferHeight
|
|
575
|
+
);
|
|
568
576
|
}
|
|
569
577
|
}
|
|
570
578
|
/**
|
|
@@ -602,7 +610,7 @@ var AnimationLoop = class {
|
|
|
602
610
|
}
|
|
603
611
|
};
|
|
604
612
|
|
|
605
|
-
//
|
|
613
|
+
// dist/animation-loop/make-animation-loop.js
|
|
606
614
|
var import_core3 = require("@luma.gl/core");
|
|
607
615
|
function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
608
616
|
let renderLoop = null;
|
|
@@ -623,18 +631,18 @@ function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
|
623
631
|
return animationLoop;
|
|
624
632
|
}
|
|
625
633
|
|
|
626
|
-
//
|
|
627
|
-
var import_core7 = require("@luma.gl/core");
|
|
634
|
+
// dist/model/model.js
|
|
628
635
|
var import_core8 = require("@luma.gl/core");
|
|
629
636
|
var import_core9 = require("@luma.gl/core");
|
|
637
|
+
var import_core10 = require("@luma.gl/core");
|
|
630
638
|
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
631
639
|
|
|
632
|
-
//
|
|
640
|
+
// dist/shader-inputs.js
|
|
633
641
|
var import_core4 = require("@luma.gl/core");
|
|
634
642
|
var import_shadertools = require("@luma.gl/shadertools");
|
|
635
643
|
var ShaderInputs = class {
|
|
636
|
-
/**
|
|
637
|
-
* The map of modules
|
|
644
|
+
/**
|
|
645
|
+
* The map of modules
|
|
638
646
|
* @todo should should this include the resolved dependencies?
|
|
639
647
|
*/
|
|
640
648
|
modules;
|
|
@@ -685,8 +693,8 @@ var ShaderInputs = class {
|
|
|
685
693
|
// getUniformBlocks(): Record<string, Texture | Sampler> {
|
|
686
694
|
// return this.moduleUniforms;
|
|
687
695
|
// }
|
|
688
|
-
/**
|
|
689
|
-
* Return the map of modules
|
|
696
|
+
/**
|
|
697
|
+
* Return the map of modules
|
|
690
698
|
* @todo should should this include the resolved dependencies?
|
|
691
699
|
*/
|
|
692
700
|
getModules() {
|
|
@@ -719,7 +727,7 @@ var ShaderInputs = class {
|
|
|
719
727
|
}
|
|
720
728
|
};
|
|
721
729
|
|
|
722
|
-
//
|
|
730
|
+
// dist/geometry/gpu-geometry.js
|
|
723
731
|
var import_core5 = require("@luma.gl/core");
|
|
724
732
|
var GPUGeometry = class {
|
|
725
733
|
id;
|
|
@@ -811,7 +819,7 @@ function getAttributeBuffersFromGeometry(device, geometry) {
|
|
|
811
819
|
return { attributes, bufferLayout, vertexCount };
|
|
812
820
|
}
|
|
813
821
|
|
|
814
|
-
//
|
|
822
|
+
// dist/lib/pipeline-factory.js
|
|
815
823
|
var import_core6 = require("@luma.gl/core");
|
|
816
824
|
var _PipelineFactory = class {
|
|
817
825
|
device;
|
|
@@ -830,11 +838,7 @@ var _PipelineFactory = class {
|
|
|
830
838
|
const props = { ..._PipelineFactory.defaultProps, ...options };
|
|
831
839
|
const hash = this._hashRenderPipeline({ ...props });
|
|
832
840
|
if (!this._pipelineCache[hash]) {
|
|
833
|
-
const pipeline = this.device.createRenderPipeline({
|
|
834
|
-
...props,
|
|
835
|
-
vs: this.device.createShader({ stage: "vertex", source: props.vs }),
|
|
836
|
-
fs: props.fs ? this.device.createShader({ stage: "fragment", source: props.fs }) : null
|
|
837
|
-
});
|
|
841
|
+
const pipeline = this.device.createRenderPipeline({ ...props });
|
|
838
842
|
pipeline.hash = hash;
|
|
839
843
|
this._pipelineCache[hash] = pipeline;
|
|
840
844
|
this._useCounts[hash] = 0;
|
|
@@ -854,16 +858,16 @@ var _PipelineFactory = class {
|
|
|
854
858
|
// PRIVATE
|
|
855
859
|
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
856
860
|
_hashRenderPipeline(props) {
|
|
857
|
-
const vsHash = this._getHash(props.vs);
|
|
858
|
-
const fsHash = props.fs ? this._getHash(props.fs) : 0;
|
|
861
|
+
const vsHash = this._getHash(props.vs.source);
|
|
862
|
+
const fsHash = props.fs ? this._getHash(props.fs.source) : 0;
|
|
859
863
|
const varyingHash = "-";
|
|
864
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
860
865
|
switch (this.device.info.type) {
|
|
861
866
|
case "webgpu":
|
|
862
867
|
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
863
|
-
|
|
864
|
-
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;
|
|
868
|
+
return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}`;
|
|
865
869
|
default:
|
|
866
|
-
return `${vsHash}/${fsHash}V${varyingHash}`;
|
|
870
|
+
return `${vsHash}/${fsHash}V${varyingHash}BL${bufferLayoutHash}`;
|
|
867
871
|
}
|
|
868
872
|
}
|
|
869
873
|
_getHash(key) {
|
|
@@ -874,13 +878,55 @@ var _PipelineFactory = class {
|
|
|
874
878
|
}
|
|
875
879
|
};
|
|
876
880
|
var PipelineFactory = _PipelineFactory;
|
|
877
|
-
__publicField(PipelineFactory, "defaultProps", {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
881
|
+
__publicField(PipelineFactory, "defaultProps", { ...import_core6.RenderPipeline.defaultProps });
|
|
882
|
+
|
|
883
|
+
// dist/lib/shader-factory.js
|
|
884
|
+
var import_core7 = require("@luma.gl/core");
|
|
885
|
+
var _ShaderFactory = class {
|
|
886
|
+
device;
|
|
887
|
+
_cache = {};
|
|
888
|
+
/** Returns the default ShaderFactory for the given {@link Device}, creating one if necessary. */
|
|
889
|
+
static getDefaultShaderFactory(device) {
|
|
890
|
+
device._lumaData.defaultShaderFactory ||= new _ShaderFactory(device);
|
|
891
|
+
return device._lumaData.defaultShaderFactory;
|
|
892
|
+
}
|
|
893
|
+
/** @internal */
|
|
894
|
+
constructor(device) {
|
|
895
|
+
this.device = device;
|
|
896
|
+
}
|
|
897
|
+
/** Requests a {@link Shader} from the cache, creating a new Shader only if necessary. */
|
|
898
|
+
createShader(props) {
|
|
899
|
+
const key = this._hashShader(props);
|
|
900
|
+
let cacheEntry = this._cache[key];
|
|
901
|
+
if (!cacheEntry) {
|
|
902
|
+
const shader = this.device.createShader({
|
|
903
|
+
...props,
|
|
904
|
+
id: props.id ? `${props.id}-cached` : void 0
|
|
905
|
+
});
|
|
906
|
+
this._cache[key] = cacheEntry = { shader, useCount: 0 };
|
|
907
|
+
}
|
|
908
|
+
cacheEntry.useCount++;
|
|
909
|
+
return cacheEntry.shader;
|
|
910
|
+
}
|
|
911
|
+
/** Releases a previously-requested {@link Shader}, destroying it if no users remain. */
|
|
912
|
+
release(shader) {
|
|
913
|
+
const key = this._hashShader(shader);
|
|
914
|
+
const cacheEntry = this._cache[key];
|
|
915
|
+
cacheEntry.useCount--;
|
|
916
|
+
if (cacheEntry.useCount === 0) {
|
|
917
|
+
delete this._cache[key];
|
|
918
|
+
cacheEntry.shader.destroy();
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
// PRIVATE
|
|
922
|
+
_hashShader(value) {
|
|
923
|
+
return `${value.stage}:${value.source}`;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
var ShaderFactory = _ShaderFactory;
|
|
927
|
+
__publicField(ShaderFactory, "defaultProps", { ...import_core7.Shader.defaultProps });
|
|
882
928
|
|
|
883
|
-
//
|
|
929
|
+
// dist/debug/debug-shader-layout.js
|
|
884
930
|
function getDebugTableForShaderLayout(layout, name) {
|
|
885
931
|
var _a;
|
|
886
932
|
const table = {};
|
|
@@ -901,7 +947,7 @@ function getDebugTableForShaderLayout(layout, name) {
|
|
|
901
947
|
return table;
|
|
902
948
|
}
|
|
903
949
|
|
|
904
|
-
//
|
|
950
|
+
// dist/debug/debug-framebuffer.js
|
|
905
951
|
var canvas = null;
|
|
906
952
|
var ctx = null;
|
|
907
953
|
function debugFramebuffer(fbo, { id, minimap, opaque, top = "0", left = "0", rgbaScale = 1 }) {
|
|
@@ -936,7 +982,7 @@ function debugFramebuffer(fbo, { id, minimap, opaque, top = "0", left = "0", rgb
|
|
|
936
982
|
ctx.putImageData(imageData, 0, 0);
|
|
937
983
|
}
|
|
938
984
|
|
|
939
|
-
//
|
|
985
|
+
// dist/model/model.js
|
|
940
986
|
var LOG_DRAW_PRIORITY = 2;
|
|
941
987
|
var LOG_DRAW_TIMEOUT = 1e4;
|
|
942
988
|
var _Model = class {
|
|
@@ -945,6 +991,7 @@ var _Model = class {
|
|
|
945
991
|
vs;
|
|
946
992
|
fs;
|
|
947
993
|
pipelineFactory;
|
|
994
|
+
shaderFactory;
|
|
948
995
|
userData = {};
|
|
949
996
|
// Fixed properties (change can trigger pipeline rebuild)
|
|
950
997
|
/** The render pipeline GPU parameters, depth testing etc */
|
|
@@ -986,16 +1033,15 @@ var _Model = class {
|
|
|
986
1033
|
_gpuGeometry = null;
|
|
987
1034
|
_getModuleUniforms;
|
|
988
1035
|
props;
|
|
1036
|
+
_destroyed = false;
|
|
989
1037
|
constructor(device, props) {
|
|
990
1038
|
var _a, _b, _c;
|
|
991
1039
|
this.props = { ..._Model.defaultProps, ...props };
|
|
992
1040
|
props = this.props;
|
|
993
|
-
this.id = props.id || (0,
|
|
1041
|
+
this.id = props.id || (0, import_core9.uid)("model");
|
|
994
1042
|
this.device = device;
|
|
995
1043
|
Object.assign(this.userData, props.userData);
|
|
996
|
-
const moduleMap = Object.fromEntries(
|
|
997
|
-
((_a = this.props.modules) == null ? void 0 : _a.map((module2) => [module2.name, module2])) || []
|
|
998
|
-
);
|
|
1044
|
+
const moduleMap = Object.fromEntries(((_a = this.props.modules) == null ? void 0 : _a.map((module2) => [module2.name, module2])) || []);
|
|
999
1045
|
this.setShaderInputs(props.shaderInputs || new ShaderInputs(moduleMap));
|
|
1000
1046
|
const isWebGPU = this.device.info.type === "webgpu";
|
|
1001
1047
|
if (this.props.source) {
|
|
@@ -1027,6 +1073,7 @@ var _Model = class {
|
|
|
1027
1073
|
this._gpuGeometry = this.setGeometry(props.geometry);
|
|
1028
1074
|
}
|
|
1029
1075
|
this.pipelineFactory = props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
1076
|
+
this.shaderFactory = props.shaderFactory || ShaderFactory.getDefaultShaderFactory(this.device);
|
|
1030
1077
|
this.pipeline = this._updatePipeline();
|
|
1031
1078
|
this.vertexArray = device.createVertexArray({
|
|
1032
1079
|
renderPipeline: this.pipeline
|
|
@@ -1047,7 +1094,9 @@ var _Model = class {
|
|
|
1047
1094
|
this.setIndexBuffer(props.indexBuffer);
|
|
1048
1095
|
}
|
|
1049
1096
|
if (props.attributes) {
|
|
1050
|
-
this.setAttributes(props.attributes
|
|
1097
|
+
this.setAttributes(props.attributes, {
|
|
1098
|
+
ignoreUnknownAttributes: props.ignoreUnknownAttributes
|
|
1099
|
+
});
|
|
1051
1100
|
}
|
|
1052
1101
|
if (props.constantAttributes) {
|
|
1053
1102
|
this.setConstantAttributes(props.constantAttributes);
|
|
@@ -1059,7 +1108,7 @@ var _Model = class {
|
|
|
1059
1108
|
this.setUniforms(props.uniforms);
|
|
1060
1109
|
}
|
|
1061
1110
|
if (props.moduleSettings) {
|
|
1062
|
-
|
|
1111
|
+
import_core9.log.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()")();
|
|
1063
1112
|
this.updateModuleSettings(props.moduleSettings);
|
|
1064
1113
|
}
|
|
1065
1114
|
if (props.transformFeedback) {
|
|
@@ -1068,8 +1117,13 @@ var _Model = class {
|
|
|
1068
1117
|
Object.seal(this);
|
|
1069
1118
|
}
|
|
1070
1119
|
destroy() {
|
|
1120
|
+
if (this._destroyed)
|
|
1121
|
+
return;
|
|
1071
1122
|
this.pipelineFactory.release(this.pipeline);
|
|
1123
|
+
this.shaderFactory.release(this.pipeline.vs);
|
|
1124
|
+
this.shaderFactory.release(this.pipeline.fs);
|
|
1072
1125
|
this._uniformStore.destroy();
|
|
1126
|
+
this._destroyed = true;
|
|
1073
1127
|
}
|
|
1074
1128
|
// Draw call
|
|
1075
1129
|
predraw() {
|
|
@@ -1081,7 +1135,7 @@ var _Model = class {
|
|
|
1081
1135
|
this._logDrawCallStart();
|
|
1082
1136
|
this.pipeline = this._updatePipeline();
|
|
1083
1137
|
this.pipeline.setBindings(this.bindings);
|
|
1084
|
-
this.pipeline.
|
|
1138
|
+
this.pipeline.setUniformsWebGL(this.uniforms);
|
|
1085
1139
|
const { indexBuffer } = this.vertexArray;
|
|
1086
1140
|
const indexCount = indexBuffer ? indexBuffer.byteLength / (indexBuffer.indexType === "uint32" ? 4 : 2) : void 0;
|
|
1087
1141
|
this.pipeline.draw({
|
|
@@ -1126,8 +1180,8 @@ var _Model = class {
|
|
|
1126
1180
|
}
|
|
1127
1181
|
this.vertexCount = gpuGeometry.vertexCount;
|
|
1128
1182
|
this.setIndexBuffer(gpuGeometry.indices);
|
|
1129
|
-
this.setAttributes(gpuGeometry.attributes,
|
|
1130
|
-
this.setAttributes(attributes);
|
|
1183
|
+
this.setAttributes(gpuGeometry.attributes, { ignoreUnknownAttributes: true });
|
|
1184
|
+
this.setAttributes(attributes, { ignoreUnknownAttributes: this.props.ignoreUnknownAttributes });
|
|
1131
1185
|
}
|
|
1132
1186
|
/**
|
|
1133
1187
|
* Updates the primitive topology ('triangle-list', 'triangle-strip' etc).
|
|
@@ -1141,7 +1195,7 @@ var _Model = class {
|
|
|
1141
1195
|
}
|
|
1142
1196
|
/**
|
|
1143
1197
|
* Updates the buffer layout.
|
|
1144
|
-
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
1198
|
+
* @note Triggers a pipeline rebuild / pipeline cache fetch
|
|
1145
1199
|
*/
|
|
1146
1200
|
setBufferLayout(bufferLayout) {
|
|
1147
1201
|
this.bufferLayout = this._gpuGeometry ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout) : bufferLayout;
|
|
@@ -1160,7 +1214,7 @@ var _Model = class {
|
|
|
1160
1214
|
* @param parameters
|
|
1161
1215
|
*/
|
|
1162
1216
|
setParameters(parameters) {
|
|
1163
|
-
if (!(0,
|
|
1217
|
+
if (!(0, import_core9.deepEqual)(parameters, this.parameters, 2)) {
|
|
1164
1218
|
this.parameters = parameters;
|
|
1165
1219
|
this._setPipelineNeedsUpdate("parameters");
|
|
1166
1220
|
}
|
|
@@ -1182,7 +1236,7 @@ var _Model = class {
|
|
|
1182
1236
|
}
|
|
1183
1237
|
setShaderInputs(shaderInputs) {
|
|
1184
1238
|
this.shaderInputs = shaderInputs;
|
|
1185
|
-
this._uniformStore = new
|
|
1239
|
+
this._uniformStore = new import_core8.UniformStore(this.shaderInputs.modules);
|
|
1186
1240
|
for (const moduleName of Object.keys(this.shaderInputs.modules)) {
|
|
1187
1241
|
const uniformBuffer = this._uniformStore.getManagedUniformBuffer(this.device, moduleName);
|
|
1188
1242
|
this.bindings[`${moduleName}Uniforms`] = uniformBuffer;
|
|
@@ -1195,7 +1249,7 @@ var _Model = class {
|
|
|
1195
1249
|
const uniforms = this._getModuleUniforms(props);
|
|
1196
1250
|
const keys = Object.keys(uniforms).filter((k) => {
|
|
1197
1251
|
const uniform = uniforms[k];
|
|
1198
|
-
return !(0,
|
|
1252
|
+
return !(0, import_core9.isNumberArray)(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
|
|
1199
1253
|
});
|
|
1200
1254
|
const bindings = {};
|
|
1201
1255
|
for (const k of keys) {
|
|
@@ -1210,8 +1264,8 @@ var _Model = class {
|
|
|
1210
1264
|
* @deprecated Updates shader module settings (which results in uniforms being set)
|
|
1211
1265
|
*/
|
|
1212
1266
|
updateModuleSettings(props) {
|
|
1213
|
-
|
|
1214
|
-
const { bindings, uniforms } = (0,
|
|
1267
|
+
import_core9.log.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()")();
|
|
1268
|
+
const { bindings, uniforms } = (0, import_core9.splitUniformsAndBindings)(this._getModuleUniforms(props));
|
|
1215
1269
|
Object.assign(this.bindings, bindings);
|
|
1216
1270
|
Object.assign(this.uniforms, uniforms);
|
|
1217
1271
|
}
|
|
@@ -1228,7 +1282,7 @@ var _Model = class {
|
|
|
1228
1282
|
* @returns self for chaining
|
|
1229
1283
|
*/
|
|
1230
1284
|
setUniforms(uniforms) {
|
|
1231
|
-
this.pipeline.
|
|
1285
|
+
this.pipeline.setUniformsWebGL(uniforms);
|
|
1232
1286
|
Object.assign(this.uniforms, uniforms);
|
|
1233
1287
|
}
|
|
1234
1288
|
/**
|
|
@@ -1239,7 +1293,7 @@ var _Model = class {
|
|
|
1239
1293
|
this.vertexArray.setIndexBuffer(indexBuffer);
|
|
1240
1294
|
}
|
|
1241
1295
|
/**
|
|
1242
|
-
* Updates optional transform feedback. WebGL
|
|
1296
|
+
* Updates optional transform feedback. WebGL only.
|
|
1243
1297
|
*/
|
|
1244
1298
|
setTransformFeedback(transformFeedback) {
|
|
1245
1299
|
this.transformFeedback = transformFeedback;
|
|
@@ -1248,16 +1302,14 @@ var _Model = class {
|
|
|
1248
1302
|
* Sets attributes (buffers)
|
|
1249
1303
|
* @note Overrides any attributes previously set with the same name
|
|
1250
1304
|
*/
|
|
1251
|
-
setAttributes(buffers,
|
|
1305
|
+
setAttributes(buffers, options) {
|
|
1252
1306
|
if (buffers.indices) {
|
|
1253
|
-
|
|
1254
|
-
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
1255
|
-
)();
|
|
1307
|
+
import_core9.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
|
|
1256
1308
|
}
|
|
1257
1309
|
for (const [bufferName, buffer] of Object.entries(buffers)) {
|
|
1258
1310
|
const bufferLayout = this.bufferLayout.find((layout) => getAttributeNames(layout).includes(bufferName));
|
|
1259
1311
|
if (!bufferLayout) {
|
|
1260
|
-
|
|
1312
|
+
import_core9.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
|
|
1261
1313
|
continue;
|
|
1262
1314
|
}
|
|
1263
1315
|
const attributeNames = getAttributeNames(bufferLayout);
|
|
@@ -1269,10 +1321,8 @@ var _Model = class {
|
|
|
1269
1321
|
set = true;
|
|
1270
1322
|
}
|
|
1271
1323
|
}
|
|
1272
|
-
if (!set &&
|
|
1273
|
-
|
|
1274
|
-
`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`
|
|
1275
|
-
)();
|
|
1324
|
+
if (!set && ((options == null ? void 0 : options.ignoreUnknownAttributes) || this.props.ignoreUnknownAttributes)) {
|
|
1325
|
+
import_core9.log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
|
|
1276
1326
|
}
|
|
1277
1327
|
}
|
|
1278
1328
|
}
|
|
@@ -1288,11 +1338,9 @@ var _Model = class {
|
|
|
1288
1338
|
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
1289
1339
|
const attributeInfo = this._attributeInfos[attributeName];
|
|
1290
1340
|
if (attributeInfo) {
|
|
1291
|
-
this.vertexArray.
|
|
1341
|
+
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
1292
1342
|
} else {
|
|
1293
|
-
|
|
1294
|
-
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
1295
|
-
)();
|
|
1343
|
+
import_core9.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
1296
1344
|
}
|
|
1297
1345
|
}
|
|
1298
1346
|
}
|
|
@@ -1301,24 +1349,27 @@ var _Model = class {
|
|
|
1301
1349
|
}
|
|
1302
1350
|
_updatePipeline() {
|
|
1303
1351
|
if (this._pipelineNeedsUpdate) {
|
|
1352
|
+
let prevShaderVs = null;
|
|
1353
|
+
let prevShaderFs = null;
|
|
1304
1354
|
if (this.pipeline) {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
)();
|
|
1355
|
+
import_core9.log.log(1, `Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)();
|
|
1356
|
+
prevShaderVs = this.pipeline.vs;
|
|
1357
|
+
prevShaderFs = this.pipeline.fs;
|
|
1309
1358
|
}
|
|
1310
1359
|
this._pipelineNeedsUpdate = false;
|
|
1311
|
-
const vs = this.
|
|
1360
|
+
const vs = this.shaderFactory.createShader({
|
|
1312
1361
|
id: `${this.id}-vertex`,
|
|
1313
1362
|
stage: "vertex",
|
|
1314
|
-
source: this.vs
|
|
1363
|
+
source: this.vs,
|
|
1364
|
+
debug: this.props.debugShaders
|
|
1315
1365
|
});
|
|
1316
|
-
const fs = this.fs ? this.
|
|
1366
|
+
const fs = this.fs ? this.shaderFactory.createShader({
|
|
1317
1367
|
id: `${this.id}-fragment`,
|
|
1318
1368
|
stage: "fragment",
|
|
1319
|
-
source: this.fs
|
|
1369
|
+
source: this.fs,
|
|
1370
|
+
debug: this.props.debugShaders
|
|
1320
1371
|
}) : null;
|
|
1321
|
-
this.pipeline = this.
|
|
1372
|
+
this.pipeline = this.pipelineFactory.createRenderPipeline({
|
|
1322
1373
|
...this.props,
|
|
1323
1374
|
bufferLayout: this.bufferLayout,
|
|
1324
1375
|
topology: this.topology,
|
|
@@ -1326,10 +1377,11 @@ var _Model = class {
|
|
|
1326
1377
|
vs,
|
|
1327
1378
|
fs
|
|
1328
1379
|
});
|
|
1329
|
-
this._attributeInfos = (0,
|
|
1330
|
-
|
|
1331
|
-
this.
|
|
1332
|
-
)
|
|
1380
|
+
this._attributeInfos = (0, import_core10.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout, this.bufferLayout);
|
|
1381
|
+
if (prevShaderVs)
|
|
1382
|
+
this.shaderFactory.release(prevShaderVs);
|
|
1383
|
+
if (prevShaderFs)
|
|
1384
|
+
this.shaderFactory.release(prevShaderFs);
|
|
1333
1385
|
}
|
|
1334
1386
|
return this.pipeline;
|
|
1335
1387
|
}
|
|
@@ -1337,33 +1389,33 @@ var _Model = class {
|
|
|
1337
1389
|
_lastLogTime = 0;
|
|
1338
1390
|
_logOpen = false;
|
|
1339
1391
|
_logDrawCallStart() {
|
|
1340
|
-
const logDrawTimeout =
|
|
1341
|
-
if (
|
|
1392
|
+
const logDrawTimeout = import_core9.log.level > 3 ? 0 : LOG_DRAW_TIMEOUT;
|
|
1393
|
+
if (import_core9.log.level < 2 || Date.now() - this._lastLogTime < logDrawTimeout) {
|
|
1342
1394
|
return;
|
|
1343
1395
|
}
|
|
1344
1396
|
this._lastLogTime = Date.now();
|
|
1345
1397
|
this._logOpen = true;
|
|
1346
|
-
|
|
1398
|
+
import_core9.log.group(LOG_DRAW_PRIORITY, `>>> DRAWING MODEL ${this.id}`, { collapsed: import_core9.log.level <= 2 })();
|
|
1347
1399
|
}
|
|
1348
1400
|
_logDrawCallEnd() {
|
|
1349
1401
|
if (this._logOpen) {
|
|
1350
1402
|
const shaderLayoutTable = getDebugTableForShaderLayout(this.pipeline.shaderLayout, this.id);
|
|
1351
|
-
|
|
1403
|
+
import_core9.log.table(LOG_DRAW_PRIORITY, shaderLayoutTable)();
|
|
1352
1404
|
const uniformTable = this.shaderInputs.getDebugTable();
|
|
1353
1405
|
for (const [name, value] of Object.entries(this.uniforms)) {
|
|
1354
1406
|
uniformTable[name] = { value };
|
|
1355
1407
|
}
|
|
1356
|
-
|
|
1408
|
+
import_core9.log.table(LOG_DRAW_PRIORITY, uniformTable)();
|
|
1357
1409
|
const attributeTable = this._getAttributeDebugTable();
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1410
|
+
import_core9.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
|
|
1411
|
+
import_core9.log.table(LOG_DRAW_PRIORITY, attributeTable)();
|
|
1412
|
+
import_core9.log.groupEnd(LOG_DRAW_PRIORITY)();
|
|
1361
1413
|
this._logOpen = false;
|
|
1362
1414
|
}
|
|
1363
1415
|
}
|
|
1364
1416
|
_drawCount = 0;
|
|
1365
1417
|
_logFramebuffer(renderPass) {
|
|
1366
|
-
const debugFramebuffers =
|
|
1418
|
+
const debugFramebuffers = import_core9.log.get("framebuffer");
|
|
1367
1419
|
this._drawCount++;
|
|
1368
1420
|
if (!debugFramebuffers || this._drawCount++ > 3 && this._drawCount % 60) {
|
|
1369
1421
|
return;
|
|
@@ -1379,10 +1431,7 @@ var _Model = class {
|
|
|
1379
1431
|
table[attributeInfo.location] = {
|
|
1380
1432
|
name,
|
|
1381
1433
|
type: attributeInfo.shaderType,
|
|
1382
|
-
values: this._getBufferOrConstantValues(
|
|
1383
|
-
this.vertexArray.attributes[attributeInfo.location],
|
|
1384
|
-
attributeInfo.bufferDataType
|
|
1385
|
-
)
|
|
1434
|
+
values: this._getBufferOrConstantValues(this.vertexArray.attributes[attributeInfo.location], attributeInfo.bufferDataType)
|
|
1386
1435
|
};
|
|
1387
1436
|
}
|
|
1388
1437
|
if (this.vertexArray.indexBuffer) {
|
|
@@ -1398,14 +1447,14 @@ var _Model = class {
|
|
|
1398
1447
|
}
|
|
1399
1448
|
// TODO - fix typing of luma data types
|
|
1400
1449
|
_getBufferOrConstantValues(attribute, dataType) {
|
|
1401
|
-
const TypedArrayConstructor = (0,
|
|
1402
|
-
const typedArray = attribute instanceof
|
|
1450
|
+
const TypedArrayConstructor = (0, import_core10.getTypedArrayFromDataType)(dataType);
|
|
1451
|
+
const typedArray = attribute instanceof import_core8.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
|
|
1403
1452
|
return typedArray.toString();
|
|
1404
1453
|
}
|
|
1405
1454
|
};
|
|
1406
1455
|
var Model = _Model;
|
|
1407
1456
|
__publicField(Model, "defaultProps", {
|
|
1408
|
-
...
|
|
1457
|
+
...import_core8.RenderPipeline.defaultProps,
|
|
1409
1458
|
source: null,
|
|
1410
1459
|
vs: null,
|
|
1411
1460
|
fs: null,
|
|
@@ -1422,8 +1471,11 @@ __publicField(Model, "defaultProps", {
|
|
|
1422
1471
|
varyings: [],
|
|
1423
1472
|
shaderInputs: void 0,
|
|
1424
1473
|
pipelineFactory: void 0,
|
|
1474
|
+
shaderFactory: void 0,
|
|
1425
1475
|
transformFeedback: void 0,
|
|
1426
|
-
shaderAssembler: import_shadertools2.ShaderAssembler.getDefaultShaderAssembler()
|
|
1476
|
+
shaderAssembler: import_shadertools2.ShaderAssembler.getDefaultShaderAssembler(),
|
|
1477
|
+
debugShaders: void 0,
|
|
1478
|
+
ignoreUnknownAttributes: void 0
|
|
1427
1479
|
});
|
|
1428
1480
|
function mergeBufferLayouts(layouts1, layouts2) {
|
|
1429
1481
|
const layouts = [...layouts1];
|
|
@@ -1443,6 +1495,7 @@ function getPlatformInfo(device) {
|
|
|
1443
1495
|
shaderLanguage: device.info.shadingLanguage,
|
|
1444
1496
|
shaderLanguageVersion: device.info.shadingLanguageVersion,
|
|
1445
1497
|
gpu: device.info.gpu,
|
|
1498
|
+
// HACK - we pretend that the DeviceFeatures is a Set, it has a similar API
|
|
1446
1499
|
features: device.features
|
|
1447
1500
|
};
|
|
1448
1501
|
}
|
|
@@ -1451,8 +1504,8 @@ function getAttributeNames(bufferLayout) {
|
|
|
1451
1504
|
return bufferLayout.attributes ? (_a = bufferLayout.attributes) == null ? void 0 : _a.map((layout) => layout.attribute) : [bufferLayout.name];
|
|
1452
1505
|
}
|
|
1453
1506
|
|
|
1454
|
-
//
|
|
1455
|
-
var
|
|
1507
|
+
// dist/transform/buffer-transform.js
|
|
1508
|
+
var import_core11 = require("@luma.gl/core");
|
|
1456
1509
|
var import_shadertools3 = require("@luma.gl/shadertools");
|
|
1457
1510
|
var BufferTransform = class {
|
|
1458
1511
|
device;
|
|
@@ -1460,14 +1513,15 @@ var BufferTransform = class {
|
|
|
1460
1513
|
transformFeedback;
|
|
1461
1514
|
/** @deprecated Use device feature test. */
|
|
1462
1515
|
static isSupported(device) {
|
|
1463
|
-
|
|
1516
|
+
var _a;
|
|
1517
|
+
return ((_a = device == null ? void 0 : device.info) == null ? void 0 : _a.type) === "webgl";
|
|
1464
1518
|
}
|
|
1465
1519
|
constructor(device, props = Model.defaultProps) {
|
|
1466
|
-
(0,
|
|
1520
|
+
(0, import_core11.assert)(BufferTransform.isSupported(device), "BufferTransform not yet implemented on WebGPU");
|
|
1467
1521
|
this.device = device;
|
|
1468
1522
|
this.model = new Model(this.device, {
|
|
1469
1523
|
id: props.id || "buffer-transform-model",
|
|
1470
|
-
fs: props.fs || (0, import_shadertools3.getPassthroughFS)(
|
|
1524
|
+
fs: props.fs || (0, import_shadertools3.getPassthroughFS)(),
|
|
1471
1525
|
topology: props.topology || "point-list",
|
|
1472
1526
|
...props
|
|
1473
1527
|
});
|
|
@@ -1504,7 +1558,7 @@ var BufferTransform = class {
|
|
|
1504
1558
|
}
|
|
1505
1559
|
readAsync(varyingName) {
|
|
1506
1560
|
const result = this.getBuffer(varyingName);
|
|
1507
|
-
if (result instanceof
|
|
1561
|
+
if (result instanceof import_core11.Buffer) {
|
|
1508
1562
|
return result.readAsync();
|
|
1509
1563
|
}
|
|
1510
1564
|
const { buffer, byteOffset = 0, byteLength = buffer.byteLength } = result;
|
|
@@ -1512,7 +1566,7 @@ var BufferTransform = class {
|
|
|
1512
1566
|
}
|
|
1513
1567
|
};
|
|
1514
1568
|
|
|
1515
|
-
//
|
|
1569
|
+
// dist/transform/texture-transform.js
|
|
1516
1570
|
var import_shadertools4 = require("@luma.gl/shadertools");
|
|
1517
1571
|
var FS_OUTPUT_VARIABLE = "transform_output";
|
|
1518
1572
|
var TextureTransform = class {
|
|
@@ -1537,7 +1591,6 @@ var TextureTransform = class {
|
|
|
1537
1591
|
this.model = new Model(this.device, {
|
|
1538
1592
|
id: props.id || "texture-transform-model",
|
|
1539
1593
|
fs: props.fs || (0, import_shadertools4.getPassthroughFS)({
|
|
1540
|
-
version: 300,
|
|
1541
1594
|
input: props.targetTextureVarying,
|
|
1542
1595
|
inputChannels: props.targetTextureChannels,
|
|
1543
1596
|
output: FS_OUTPUT_VARIABLE
|
|
@@ -1620,11 +1673,11 @@ var TextureTransform = class {
|
|
|
1620
1673
|
}
|
|
1621
1674
|
};
|
|
1622
1675
|
|
|
1623
|
-
//
|
|
1624
|
-
var
|
|
1676
|
+
// dist/lib/clip-space.js
|
|
1677
|
+
var import_core13 = require("@luma.gl/core");
|
|
1625
1678
|
|
|
1626
|
-
//
|
|
1627
|
-
var
|
|
1679
|
+
// dist/geometry/geometry.js
|
|
1680
|
+
var import_core12 = require("@luma.gl/core");
|
|
1628
1681
|
var Geometry = class {
|
|
1629
1682
|
id;
|
|
1630
1683
|
/** Determines how vertices are read from the 'vertex' attributes */
|
|
@@ -1635,7 +1688,7 @@ var Geometry = class {
|
|
|
1635
1688
|
userData = {};
|
|
1636
1689
|
constructor(props) {
|
|
1637
1690
|
const { attributes = {}, indices = null, vertexCount = null } = props;
|
|
1638
|
-
this.id = props.id || (0,
|
|
1691
|
+
this.id = props.id || (0, import_core12.uid)("geometry");
|
|
1639
1692
|
this.topology = props.topology;
|
|
1640
1693
|
if (indices) {
|
|
1641
1694
|
this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
|
|
@@ -1643,15 +1696,12 @@ var Geometry = class {
|
|
|
1643
1696
|
this.attributes = {};
|
|
1644
1697
|
for (const [attributeName, attributeValue] of Object.entries(attributes)) {
|
|
1645
1698
|
const attribute = ArrayBuffer.isView(attributeValue) ? { value: attributeValue } : attributeValue;
|
|
1646
|
-
(0,
|
|
1647
|
-
ArrayBuffer.isView(attribute.value),
|
|
1648
|
-
`${this._print(attributeName)}: must be typed array or object with value as typed array`
|
|
1649
|
-
);
|
|
1699
|
+
(0, import_core12.assert)(ArrayBuffer.isView(attribute.value), `${this._print(attributeName)}: must be typed array or object with value as typed array`);
|
|
1650
1700
|
if ((attributeName === "POSITION" || attributeName === "positions") && !attribute.size) {
|
|
1651
1701
|
attribute.size = 3;
|
|
1652
1702
|
}
|
|
1653
1703
|
if (attributeName === "indices") {
|
|
1654
|
-
(0,
|
|
1704
|
+
(0, import_core12.assert)(!this.indices);
|
|
1655
1705
|
this.indices = attribute;
|
|
1656
1706
|
} else {
|
|
1657
1707
|
this.attributes[attributeName] = attribute;
|
|
@@ -1666,7 +1716,7 @@ var Geometry = class {
|
|
|
1666
1716
|
getVertexCount() {
|
|
1667
1717
|
return this.vertexCount;
|
|
1668
1718
|
}
|
|
1669
|
-
/**
|
|
1719
|
+
/**
|
|
1670
1720
|
* Return an object with all attributes plus indices added as a field.
|
|
1671
1721
|
* TODO Geometry types are a mess
|
|
1672
1722
|
*/
|
|
@@ -1683,10 +1733,10 @@ var Geometry = class {
|
|
|
1683
1733
|
* type: indices, vertices, uvs
|
|
1684
1734
|
* size: elements per vertex
|
|
1685
1735
|
* target: WebGL buffer type (string or constant)
|
|
1686
|
-
*
|
|
1687
|
-
* @param attributes
|
|
1688
|
-
* @param indices
|
|
1689
|
-
* @returns
|
|
1736
|
+
*
|
|
1737
|
+
* @param attributes
|
|
1738
|
+
* @param indices
|
|
1739
|
+
* @returns
|
|
1690
1740
|
*/
|
|
1691
1741
|
_setAttributes(attributes, indices) {
|
|
1692
1742
|
return this;
|
|
@@ -1702,13 +1752,13 @@ var Geometry = class {
|
|
|
1702
1752
|
vertexCount = Math.min(vertexCount, value.length / size);
|
|
1703
1753
|
}
|
|
1704
1754
|
}
|
|
1705
|
-
(0,
|
|
1755
|
+
(0, import_core12.assert)(Number.isFinite(vertexCount));
|
|
1706
1756
|
return vertexCount;
|
|
1707
1757
|
}
|
|
1708
1758
|
};
|
|
1709
1759
|
|
|
1710
|
-
//
|
|
1711
|
-
var CLIPSPACE_VERTEX_SHADER =
|
|
1760
|
+
// dist/lib/clip-space.js
|
|
1761
|
+
var CLIPSPACE_VERTEX_SHADER = import_core13.glsl`\
|
|
1712
1762
|
#version 300 es
|
|
1713
1763
|
in vec2 aClipSpacePosition;
|
|
1714
1764
|
in vec2 aTexCoord;
|
|
@@ -1729,41 +1779,38 @@ var POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
|
1729
1779
|
var ClipSpace = class extends Model {
|
|
1730
1780
|
constructor(device, opts) {
|
|
1731
1781
|
const TEX_COORDS = POSITIONS.map((coord) => coord === -1 ? 0 : coord);
|
|
1732
|
-
super(
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1782
|
+
super(device, {
|
|
1783
|
+
...opts,
|
|
1784
|
+
vs: CLIPSPACE_VERTEX_SHADER,
|
|
1785
|
+
vertexCount: 4,
|
|
1786
|
+
geometry: new Geometry({
|
|
1787
|
+
topology: "triangle-strip",
|
|
1737
1788
|
vertexCount: 4,
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
}
|
|
1746
|
-
})
|
|
1747
|
-
}
|
|
1748
|
-
);
|
|
1789
|
+
attributes: {
|
|
1790
|
+
aClipSpacePosition: { size: 2, value: new Float32Array(POSITIONS) },
|
|
1791
|
+
aTexCoord: { size: 2, value: new Float32Array(TEX_COORDS) },
|
|
1792
|
+
aCoordinate: { size: 2, value: new Float32Array(TEX_COORDS) }
|
|
1793
|
+
}
|
|
1794
|
+
})
|
|
1795
|
+
});
|
|
1749
1796
|
}
|
|
1750
1797
|
};
|
|
1751
1798
|
|
|
1752
|
-
//
|
|
1753
|
-
var
|
|
1754
|
-
var
|
|
1799
|
+
// dist/scenegraph/scenegraph-node.js
|
|
1800
|
+
var import_core14 = require("@luma.gl/core");
|
|
1801
|
+
var import_core15 = require("@math.gl/core");
|
|
1755
1802
|
var ScenegraphNode = class {
|
|
1756
1803
|
id;
|
|
1757
|
-
matrix = new
|
|
1804
|
+
matrix = new import_core15.Matrix4();
|
|
1758
1805
|
display = true;
|
|
1759
|
-
position = new
|
|
1760
|
-
rotation = new
|
|
1761
|
-
scale = new
|
|
1806
|
+
position = new import_core15.Vector3();
|
|
1807
|
+
rotation = new import_core15.Vector3();
|
|
1808
|
+
scale = new import_core15.Vector3(1, 1, 1);
|
|
1762
1809
|
userData = {};
|
|
1763
1810
|
props = {};
|
|
1764
1811
|
constructor(props = {}) {
|
|
1765
1812
|
const { id } = props;
|
|
1766
|
-
this.id = id || (0,
|
|
1813
|
+
this.id = id || (0, import_core14.uid)(this.constructor.name);
|
|
1767
1814
|
this._setScenegraphNodeProps(props);
|
|
1768
1815
|
}
|
|
1769
1816
|
getBounds() {
|
|
@@ -1783,17 +1830,17 @@ var ScenegraphNode = class {
|
|
|
1783
1830
|
return `{type: ScenegraphNode, id: ${this.id})}`;
|
|
1784
1831
|
}
|
|
1785
1832
|
setPosition(position) {
|
|
1786
|
-
(0,
|
|
1833
|
+
(0, import_core14.assert)(position.length === 3, "setPosition requires vector argument");
|
|
1787
1834
|
this.position = position;
|
|
1788
1835
|
return this;
|
|
1789
1836
|
}
|
|
1790
1837
|
setRotation(rotation) {
|
|
1791
|
-
(0,
|
|
1838
|
+
(0, import_core14.assert)(rotation.length === 3, "setRotation requires vector argument");
|
|
1792
1839
|
this.rotation = rotation;
|
|
1793
1840
|
return this;
|
|
1794
1841
|
}
|
|
1795
1842
|
setScale(scale) {
|
|
1796
|
-
(0,
|
|
1843
|
+
(0, import_core14.assert)(scale.length === 3, "setScale requires vector argument");
|
|
1797
1844
|
this.scale = scale;
|
|
1798
1845
|
return this;
|
|
1799
1846
|
}
|
|
@@ -1845,9 +1892,9 @@ var ScenegraphNode = class {
|
|
|
1845
1892
|
return this;
|
|
1846
1893
|
}
|
|
1847
1894
|
getCoordinateUniforms(viewMatrix, modelMatrix) {
|
|
1848
|
-
(0,
|
|
1895
|
+
(0, import_core14.assert)(viewMatrix);
|
|
1849
1896
|
modelMatrix = modelMatrix || this.matrix;
|
|
1850
|
-
const worldMatrix = new
|
|
1897
|
+
const worldMatrix = new import_core15.Matrix4(viewMatrix).multiplyRight(modelMatrix);
|
|
1851
1898
|
const worldInverse = worldMatrix.invert();
|
|
1852
1899
|
const worldInverseTranspose = worldInverse.transpose();
|
|
1853
1900
|
return {
|
|
@@ -1901,39 +1948,35 @@ var ScenegraphNode = class {
|
|
|
1901
1948
|
}
|
|
1902
1949
|
};
|
|
1903
1950
|
|
|
1904
|
-
//
|
|
1905
|
-
var
|
|
1906
|
-
var
|
|
1951
|
+
// dist/scenegraph/group-node.js
|
|
1952
|
+
var import_core16 = require("@math.gl/core");
|
|
1953
|
+
var import_core17 = require("@luma.gl/core");
|
|
1907
1954
|
var GroupNode = class extends ScenegraphNode {
|
|
1908
1955
|
children;
|
|
1909
1956
|
constructor(props = {}) {
|
|
1910
1957
|
props = Array.isArray(props) ? { children: props } : props;
|
|
1911
1958
|
const { children = [] } = props;
|
|
1912
|
-
|
|
1913
|
-
children.every((child) => child instanceof ScenegraphNode),
|
|
1914
|
-
"every child must an instance of ScenegraphNode"
|
|
1915
|
-
);
|
|
1959
|
+
import_core17.log.assert(children.every((child) => child instanceof ScenegraphNode), "every child must an instance of ScenegraphNode");
|
|
1916
1960
|
super(props);
|
|
1917
1961
|
this.children = children;
|
|
1918
1962
|
}
|
|
1919
1963
|
getBounds() {
|
|
1920
|
-
const result = [
|
|
1964
|
+
const result = [
|
|
1965
|
+
[Infinity, Infinity, Infinity],
|
|
1966
|
+
[-Infinity, -Infinity, -Infinity]
|
|
1967
|
+
];
|
|
1921
1968
|
this.traverse((node, { worldMatrix }) => {
|
|
1922
1969
|
const bounds = node.getBounds();
|
|
1923
1970
|
if (!bounds) {
|
|
1924
1971
|
return;
|
|
1925
1972
|
}
|
|
1926
1973
|
const [min, max] = bounds;
|
|
1927
|
-
const center = new
|
|
1974
|
+
const center = new import_core16.Vector3(min).add(max).divide([2, 2, 2]);
|
|
1928
1975
|
worldMatrix.transformAsPoint(center, center);
|
|
1929
|
-
const halfSize = new
|
|
1976
|
+
const halfSize = new import_core16.Vector3(max).subtract(min).divide([2, 2, 2]);
|
|
1930
1977
|
worldMatrix.transformAsVector(halfSize, halfSize);
|
|
1931
1978
|
for (let v = 0; v < 8; v++) {
|
|
1932
|
-
const position = new
|
|
1933
|
-
v & 1 ? -1 : 1,
|
|
1934
|
-
v & 2 ? -1 : 1,
|
|
1935
|
-
v & 4 ? -1 : 1
|
|
1936
|
-
).multiply(halfSize).add(center);
|
|
1979
|
+
const position = new import_core16.Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center);
|
|
1937
1980
|
for (let i = 0; i < 3; i++) {
|
|
1938
1981
|
result[0][i] = Math.min(result[0][i], position[i]);
|
|
1939
1982
|
result[1][i] = Math.max(result[1][i], position[i]);
|
|
@@ -1973,8 +2016,8 @@ var GroupNode = class extends ScenegraphNode {
|
|
|
1973
2016
|
this.children = [];
|
|
1974
2017
|
return this;
|
|
1975
2018
|
}
|
|
1976
|
-
traverse(visitor, { worldMatrix = new
|
|
1977
|
-
const modelMatrix = new
|
|
2019
|
+
traverse(visitor, { worldMatrix = new import_core16.Matrix4() } = {}) {
|
|
2020
|
+
const modelMatrix = new import_core16.Matrix4(worldMatrix).multiplyRight(this.matrix);
|
|
1978
2021
|
for (const child of this.children) {
|
|
1979
2022
|
if (child instanceof GroupNode) {
|
|
1980
2023
|
child.traverse(visitor, { worldMatrix: modelMatrix });
|
|
@@ -1985,7 +2028,7 @@ var GroupNode = class extends ScenegraphNode {
|
|
|
1985
2028
|
}
|
|
1986
2029
|
};
|
|
1987
2030
|
|
|
1988
|
-
//
|
|
2031
|
+
// dist/scenegraph/model-node.js
|
|
1989
2032
|
var ModelNode = class extends ScenegraphNode {
|
|
1990
2033
|
model;
|
|
1991
2034
|
bounds = null;
|
|
@@ -2018,11 +2061,11 @@ var ModelNode = class extends ScenegraphNode {
|
|
|
2018
2061
|
}
|
|
2019
2062
|
};
|
|
2020
2063
|
|
|
2021
|
-
//
|
|
2022
|
-
var
|
|
2064
|
+
// dist/geometries/cone-geometry.js
|
|
2065
|
+
var import_core19 = require("@luma.gl/core");
|
|
2023
2066
|
|
|
2024
|
-
//
|
|
2025
|
-
var
|
|
2067
|
+
// dist/geometries/truncated-cone-geometry.js
|
|
2068
|
+
var import_core18 = require("@luma.gl/core");
|
|
2026
2069
|
var INDEX_OFFSETS = {
|
|
2027
2070
|
x: [2, 0, 1],
|
|
2028
2071
|
y: [0, 1, 2],
|
|
@@ -2030,7 +2073,7 @@ var INDEX_OFFSETS = {
|
|
|
2030
2073
|
};
|
|
2031
2074
|
var TruncatedConeGeometry = class extends Geometry {
|
|
2032
2075
|
constructor(props = {}) {
|
|
2033
|
-
const { id = (0,
|
|
2076
|
+
const { id = (0, import_core18.uid)("truncated-code-geometry") } = props;
|
|
2034
2077
|
const { indices, attributes } = tesselateTruncatedCone(props);
|
|
2035
2078
|
super({
|
|
2036
2079
|
...props,
|
|
@@ -2047,16 +2090,7 @@ var TruncatedConeGeometry = class extends Geometry {
|
|
|
2047
2090
|
}
|
|
2048
2091
|
};
|
|
2049
2092
|
function tesselateTruncatedCone(props = {}) {
|
|
2050
|
-
const {
|
|
2051
|
-
bottomRadius = 0,
|
|
2052
|
-
topRadius = 0,
|
|
2053
|
-
height = 1,
|
|
2054
|
-
nradial = 10,
|
|
2055
|
-
nvertical = 10,
|
|
2056
|
-
verticalAxis = "y",
|
|
2057
|
-
topCap = false,
|
|
2058
|
-
bottomCap = false
|
|
2059
|
-
} = props;
|
|
2093
|
+
const { bottomRadius = 0, topRadius = 0, height = 1, nradial = 10, nvertical = 10, verticalAxis = "y", topCap = false, bottomCap = false } = props;
|
|
2060
2094
|
const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
|
|
2061
2095
|
const numVertices = (nradial + 1) * (nvertical + 1 + extra);
|
|
2062
2096
|
const slant = Math.atan2(bottomRadius - topRadius, height);
|
|
@@ -2131,10 +2165,10 @@ function tesselateTruncatedCone(props = {}) {
|
|
|
2131
2165
|
};
|
|
2132
2166
|
}
|
|
2133
2167
|
|
|
2134
|
-
//
|
|
2168
|
+
// dist/geometries/cone-geometry.js
|
|
2135
2169
|
var ConeGeometry = class extends TruncatedConeGeometry {
|
|
2136
2170
|
constructor(props = {}) {
|
|
2137
|
-
const { id = (0,
|
|
2171
|
+
const { id = (0, import_core19.uid)("cone-geometry"), radius = 1, cap = true } = props;
|
|
2138
2172
|
super({
|
|
2139
2173
|
...props,
|
|
2140
2174
|
id,
|
|
@@ -2146,11 +2180,11 @@ var ConeGeometry = class extends TruncatedConeGeometry {
|
|
|
2146
2180
|
}
|
|
2147
2181
|
};
|
|
2148
2182
|
|
|
2149
|
-
//
|
|
2150
|
-
var
|
|
2183
|
+
// dist/geometries/cube-geometry.js
|
|
2184
|
+
var import_core20 = require("@luma.gl/core");
|
|
2151
2185
|
var CubeGeometry = class extends Geometry {
|
|
2152
2186
|
constructor(props = {}) {
|
|
2153
|
-
const { id = (0,
|
|
2187
|
+
const { id = (0, import_core20.uid)("cube-geometry"), indices = true } = props;
|
|
2154
2188
|
super(indices ? {
|
|
2155
2189
|
...props,
|
|
2156
2190
|
id,
|
|
@@ -2756,11 +2790,11 @@ var NON_INDEXED_ATTRIBUTES = {
|
|
|
2756
2790
|
COLOR_0: { size: 3, value: CUBE_NON_INDEXED_COLORS }
|
|
2757
2791
|
};
|
|
2758
2792
|
|
|
2759
|
-
//
|
|
2760
|
-
var
|
|
2793
|
+
// dist/geometries/cylinder-geometry.js
|
|
2794
|
+
var import_core21 = require("@luma.gl/core");
|
|
2761
2795
|
var CylinderGeometry = class extends TruncatedConeGeometry {
|
|
2762
2796
|
constructor(props = {}) {
|
|
2763
|
-
const { id = (0,
|
|
2797
|
+
const { id = (0, import_core21.uid)("cylinder-geometry"), radius = 1 } = props;
|
|
2764
2798
|
super({
|
|
2765
2799
|
...props,
|
|
2766
2800
|
id,
|
|
@@ -2770,14 +2804,14 @@ var CylinderGeometry = class extends TruncatedConeGeometry {
|
|
|
2770
2804
|
}
|
|
2771
2805
|
};
|
|
2772
2806
|
|
|
2773
|
-
//
|
|
2774
|
-
var
|
|
2775
|
-
var
|
|
2807
|
+
// dist/geometries/ico-sphere-geometry.js
|
|
2808
|
+
var import_core22 = require("@luma.gl/core");
|
|
2809
|
+
var import_core23 = require("@math.gl/core");
|
|
2776
2810
|
var ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
|
|
2777
2811
|
var ICO_INDICES = [3, 4, 5, 3, 5, 1, 3, 1, 0, 3, 0, 4, 4, 0, 2, 4, 2, 5, 2, 0, 1, 5, 2, 1];
|
|
2778
2812
|
var IcoSphereGeometry = class extends Geometry {
|
|
2779
2813
|
constructor(props = {}) {
|
|
2780
|
-
const { id = (0,
|
|
2814
|
+
const { id = (0, import_core22.uid)("ico-sphere-geometry") } = props;
|
|
2781
2815
|
const { indices, attributes } = tesselateIcosaHedron(props);
|
|
2782
2816
|
super({
|
|
2783
2817
|
...props,
|
|
@@ -2870,7 +2904,7 @@ function tesselateIcosaHedron(props) {
|
|
|
2870
2904
|
const u3 = 1 - phi3 / PI2;
|
|
2871
2905
|
const vec1 = [x3 - x2, y3 - y2, z3 - z2];
|
|
2872
2906
|
const vec2 = [x1 - x2, y1 - y2, z1 - z2];
|
|
2873
|
-
const normal = new
|
|
2907
|
+
const normal = new import_core23.Vector3(vec1).cross(vec2).normalize();
|
|
2874
2908
|
let newIndex;
|
|
2875
2909
|
if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
|
|
2876
2910
|
positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
|
|
@@ -2918,10 +2952,10 @@ function tesselateIcosaHedron(props) {
|
|
|
2918
2952
|
};
|
|
2919
2953
|
}
|
|
2920
2954
|
|
|
2921
|
-
//
|
|
2922
|
-
var
|
|
2955
|
+
// dist/geometries/plane-geometry.js
|
|
2956
|
+
var import_core24 = require("@luma.gl/core");
|
|
2923
2957
|
|
|
2924
|
-
//
|
|
2958
|
+
// dist/geometry/geometry-utils.js
|
|
2925
2959
|
function unpackIndexedGeometry(geometry) {
|
|
2926
2960
|
const { indices, attributes } = geometry;
|
|
2927
2961
|
if (!indices) {
|
|
@@ -2949,10 +2983,10 @@ function unpackIndexedGeometry(geometry) {
|
|
|
2949
2983
|
};
|
|
2950
2984
|
}
|
|
2951
2985
|
|
|
2952
|
-
//
|
|
2986
|
+
// dist/geometries/plane-geometry.js
|
|
2953
2987
|
var PlaneGeometry = class extends Geometry {
|
|
2954
2988
|
constructor(props = {}) {
|
|
2955
|
-
const { id = (0,
|
|
2989
|
+
const { id = (0, import_core24.uid)("plane-geometry") } = props;
|
|
2956
2990
|
const { indices, attributes } = tesselatePlane(props);
|
|
2957
2991
|
super({
|
|
2958
2992
|
...props,
|
|
@@ -3041,11 +3075,11 @@ function tesselatePlane(props) {
|
|
|
3041
3075
|
return unpack ? unpackIndexedGeometry(geometry) : geometry;
|
|
3042
3076
|
}
|
|
3043
3077
|
|
|
3044
|
-
//
|
|
3045
|
-
var
|
|
3078
|
+
// dist/geometries/sphere-geometry.js
|
|
3079
|
+
var import_core25 = require("@luma.gl/core");
|
|
3046
3080
|
var SphereGeometry = class extends Geometry {
|
|
3047
3081
|
constructor(props = {}) {
|
|
3048
|
-
const { id = (0,
|
|
3082
|
+
const { id = (0, import_core25.uid)("sphere-geometry") } = props;
|
|
3049
3083
|
const { indices, attributes } = tesselateSphere(props);
|
|
3050
3084
|
super({
|
|
3051
3085
|
...props,
|
|
@@ -3119,3 +3153,4 @@ function tesselateSphere(props) {
|
|
|
3119
3153
|
}
|
|
3120
3154
|
};
|
|
3121
3155
|
}
|
|
3156
|
+
//# sourceMappingURL=index.cjs.map
|