@luma.gl/engine 9.0.0-alpha.21 → 9.0.0-alpha.23
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-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +3 -1
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.d.ts +2 -1
- package/dist/animation-loop/animation-props.d.ts.map +1 -1
- package/dist/animation-loop/animation-props.js.map +1 -1
- package/dist/dist.dev.js +1321 -633
- package/dist/index.cjs +110 -29
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -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 +1 -1
- package/dist/lib/clip-space.js.map +1 -1
- package/dist/lib/pipeline-factory.d.ts +1 -1
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model-utils.d.ts.map +1 -0
- package/dist/model/model-utils.js.map +1 -0
- package/dist/{lib → model}/model.d.ts +7 -2
- package/dist/model/model.d.ts.map +1 -0
- package/dist/{lib → model}/model.js +10 -6
- package/dist/model/model.js.map +1 -0
- package/dist/transform/transform.d.ts +98 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/transform/transform.js +67 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist.min.js +83 -65
- package/package.json +6 -6
- package/src/animation-loop/animation-loop.ts +5 -1
- package/src/animation-loop/animation-props.ts +2 -1
- package/src/index.ts +4 -2
- package/src/lib/clip-space.ts +1 -1
- package/src/lib/pipeline-factory.ts +1 -1
- package/src/{lib → model}/model.ts +16 -7
- package/src/transform/transform.ts +246 -0
- package/dist/lib/model-utils.d.ts.map +0 -1
- package/dist/lib/model-utils.js.map +0 -1
- package/dist/lib/model.d.ts.map +0 -1
- package/dist/lib/model.js.map +0 -1
- package/src/.DS_Store +0 -0
- /package/dist/{lib → model}/model-utils.d.ts +0 -0
- /package/dist/{lib → model}/model-utils.js +0 -0
- /package/src/{lib → model}/model-utils.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -81,6 +81,7 @@ __export(src_exports, {
|
|
|
81
81
|
PlaneGeometry: () => PlaneGeometry,
|
|
82
82
|
SphereGeometry: () => SphereGeometry,
|
|
83
83
|
Timeline: () => Timeline,
|
|
84
|
+
Transform: () => Transform,
|
|
84
85
|
TruncatedConeGeometry: () => TruncatedConeGeometry,
|
|
85
86
|
makeAnimationLoop: () => makeAnimationLoop
|
|
86
87
|
});
|
|
@@ -445,7 +446,7 @@ var AnimationLoop = class {
|
|
|
445
446
|
}
|
|
446
447
|
_setDisplay(display) {
|
|
447
448
|
if (this.display) {
|
|
448
|
-
this.display.
|
|
449
|
+
this.display.destroy();
|
|
449
450
|
this.display.animationLoop = null;
|
|
450
451
|
}
|
|
451
452
|
if (display) {
|
|
@@ -499,6 +500,7 @@ var AnimationLoop = class {
|
|
|
499
500
|
animationLoop: this,
|
|
500
501
|
device: this.device,
|
|
501
502
|
canvas: (_b = (_a = this.device) == null ? void 0 : _a.canvasContext) == null ? void 0 : _b.canvas,
|
|
503
|
+
renderPass: this.device.getDefaultRenderPass(),
|
|
502
504
|
timeline: this.timeline,
|
|
503
505
|
// Initial values
|
|
504
506
|
useDevicePixels: this.props.useDevicePixels,
|
|
@@ -529,6 +531,7 @@ var AnimationLoop = class {
|
|
|
529
531
|
if (!this.animationProps) {
|
|
530
532
|
return;
|
|
531
533
|
}
|
|
534
|
+
this.animationProps.renderPass = this.device.getDefaultRenderPass();
|
|
532
535
|
const { width, height, aspect } = this._getSizeAndAspect();
|
|
533
536
|
if (width !== this.animationProps.width || height !== this.animationProps.height) {
|
|
534
537
|
this.setNeedsRedraw("drawing buffer resized");
|
|
@@ -657,10 +660,10 @@ function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
|
|
|
657
660
|
return animationLoop;
|
|
658
661
|
}
|
|
659
662
|
|
|
660
|
-
// src/
|
|
663
|
+
// src/model/model.ts
|
|
661
664
|
var import_api5 = require("@luma.gl/api");
|
|
662
665
|
|
|
663
|
-
// src/
|
|
666
|
+
// src/model/model-utils.ts
|
|
664
667
|
var import_api4 = require("@luma.gl/api");
|
|
665
668
|
var GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
666
669
|
POSITION: "positions",
|
|
@@ -850,16 +853,18 @@ var PipelineFactory = class {
|
|
|
850
853
|
}
|
|
851
854
|
};
|
|
852
855
|
|
|
853
|
-
// src/
|
|
856
|
+
// src/model/model.ts
|
|
854
857
|
var DEFAULT_MODEL_PROPS = __spreadProps(__spreadValues({}, import_api5.RenderPipeline._DEFAULT_PROPS), {
|
|
855
858
|
vs: null,
|
|
856
859
|
fs: null,
|
|
857
860
|
id: "unnamed",
|
|
858
861
|
handle: void 0,
|
|
859
862
|
userData: {},
|
|
863
|
+
defines: {},
|
|
860
864
|
modules: [],
|
|
861
865
|
moduleSettings: {},
|
|
862
|
-
geometry: null
|
|
866
|
+
geometry: null,
|
|
867
|
+
pipelineFactory: void 0
|
|
863
868
|
});
|
|
864
869
|
var Model = class {
|
|
865
870
|
constructor(device, props) {
|
|
@@ -881,11 +886,12 @@ var Model = class {
|
|
|
881
886
|
this.vertexCount = this.props.geometry.vertexCount;
|
|
882
887
|
this.topology = this.props.geometry.topology || "triangle-list";
|
|
883
888
|
}
|
|
884
|
-
|
|
885
|
-
const { pipeline, getUniforms } = pipelineFactory.createRenderPipeline(__spreadProps(__spreadValues({}, this.props), {
|
|
889
|
+
this.pipelineFactory = this.props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
890
|
+
const { pipeline, getUniforms } = this.pipelineFactory.createRenderPipeline(__spreadProps(__spreadValues({}, this.props), {
|
|
886
891
|
vs: this.vs,
|
|
887
892
|
fs: this.fs,
|
|
888
893
|
topology: this.topology,
|
|
894
|
+
defines: props.defines,
|
|
889
895
|
parameters: props.parameters,
|
|
890
896
|
layout: props.layout
|
|
891
897
|
}));
|
|
@@ -898,7 +904,7 @@ var Model = class {
|
|
|
898
904
|
this.setProps(this.props);
|
|
899
905
|
}
|
|
900
906
|
destroy() {
|
|
901
|
-
this.
|
|
907
|
+
this.pipelineFactory.release(this.pipeline);
|
|
902
908
|
}
|
|
903
909
|
draw(renderPass) {
|
|
904
910
|
this.pipeline.draw({
|
|
@@ -978,22 +984,97 @@ function getShaderSource(device, shader) {
|
|
|
978
984
|
}
|
|
979
985
|
}
|
|
980
986
|
|
|
987
|
+
// src/transform/transform.ts
|
|
988
|
+
var import_shadertools2 = require("@luma.gl/shadertools");
|
|
989
|
+
var import_constants = __toESM(require("@luma.gl/constants"), 1);
|
|
990
|
+
var import_webgl = require("@luma.gl/webgl");
|
|
991
|
+
var Transform = class {
|
|
992
|
+
constructor(device, props = {}) {
|
|
993
|
+
// model: Model;
|
|
994
|
+
this.elementCount = 0;
|
|
995
|
+
// bufferTransform: BufferTransform | null = null;
|
|
996
|
+
// textureTransform: TextureTransform | null = null;
|
|
997
|
+
this.elementIDBuffer = null;
|
|
998
|
+
this.device = import_webgl.WebGLDevice.attach(device);
|
|
999
|
+
this.gl = this.device.gl2;
|
|
1000
|
+
this._buildResourceTransforms(props);
|
|
1001
|
+
props = this._updateModelProps(props);
|
|
1002
|
+
this.model = new Model(this.device, __spreadProps(__spreadValues({}, props), {
|
|
1003
|
+
fs: props.fs || (0, import_shadertools2.getPassthroughFS)({ version: (0, import_shadertools2.getShaderInfo)(props.vs).version }),
|
|
1004
|
+
id: props.id || "transform-model",
|
|
1005
|
+
// @ts-expect-error
|
|
1006
|
+
drawMode: props.drawMode || import_constants.default.POINTS,
|
|
1007
|
+
vertexCount: props.elementCount
|
|
1008
|
+
}));
|
|
1009
|
+
Object.seal(this);
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Check if Transforms are supported (they are not under WebGL1)
|
|
1013
|
+
* @todo differentiate writing to buffer vs not
|
|
1014
|
+
*/
|
|
1015
|
+
static isSupported(device) {
|
|
1016
|
+
return false;
|
|
1017
|
+
}
|
|
1018
|
+
/** Delete owned resources. */
|
|
1019
|
+
destroy() {
|
|
1020
|
+
}
|
|
1021
|
+
/** @deprecated Use destroy*() */
|
|
1022
|
+
delete() {
|
|
1023
|
+
this.destroy();
|
|
1024
|
+
}
|
|
1025
|
+
/** Run one transform loop. */
|
|
1026
|
+
run(options) {
|
|
1027
|
+
const { clearRenderTarget = true } = options || {};
|
|
1028
|
+
const updatedOpts = this._updateDrawOptions(options);
|
|
1029
|
+
if (clearRenderTarget && updatedOpts.framebuffer) {
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
/** swap resources if a map is provided */
|
|
1033
|
+
swap() {
|
|
1034
|
+
}
|
|
1035
|
+
/** Return Buffer object for given varying name. */
|
|
1036
|
+
getBuffer(varyingName) {
|
|
1037
|
+
return null;
|
|
1038
|
+
}
|
|
1039
|
+
/** Return data either from Buffer or from Texture */
|
|
1040
|
+
getData(options = {}) {
|
|
1041
|
+
}
|
|
1042
|
+
/** Return framebuffer object if rendering to textures */
|
|
1043
|
+
getFramebuffer() {
|
|
1044
|
+
return null;
|
|
1045
|
+
}
|
|
1046
|
+
/** Update some or all buffer/texture bindings. */
|
|
1047
|
+
update(props) {
|
|
1048
|
+
}
|
|
1049
|
+
// Private
|
|
1050
|
+
_updateModelProps(props) {
|
|
1051
|
+
const updatedProps = __spreadValues({}, props);
|
|
1052
|
+
return updatedProps;
|
|
1053
|
+
}
|
|
1054
|
+
_buildResourceTransforms(props) {
|
|
1055
|
+
}
|
|
1056
|
+
_updateDrawOptions(options) {
|
|
1057
|
+
const updatedOpts = __spreadValues({}, options);
|
|
1058
|
+
return updatedOpts;
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
|
|
981
1062
|
// src/lib/clip-space.ts
|
|
982
|
-
var
|
|
1063
|
+
var import_constants3 = __toESM(require("@luma.gl/constants"), 1);
|
|
983
1064
|
var import_api7 = require("@luma.gl/api");
|
|
984
|
-
var
|
|
1065
|
+
var import_webgl2 = require("@luma.gl/webgl");
|
|
985
1066
|
|
|
986
1067
|
// src/geometry/geometry.ts
|
|
987
1068
|
var import_api6 = require("@luma.gl/api");
|
|
988
|
-
var
|
|
1069
|
+
var import_constants2 = __toESM(require("@luma.gl/constants"), 1);
|
|
989
1070
|
var Geometry = class {
|
|
990
1071
|
constructor(props = {}) {
|
|
991
1072
|
this.userData = {};
|
|
992
1073
|
/** @deprecated */
|
|
993
|
-
this.drawMode =
|
|
1074
|
+
this.drawMode = import_constants2.default.TRIANGLES;
|
|
994
1075
|
const {
|
|
995
1076
|
id = (0, import_api6.uid)("geometry"),
|
|
996
|
-
drawMode =
|
|
1077
|
+
drawMode = import_constants2.default.TRIANGLES,
|
|
997
1078
|
attributes = {},
|
|
998
1079
|
indices = null,
|
|
999
1080
|
vertexCount = null
|
|
@@ -1068,36 +1149,36 @@ var Geometry = class {
|
|
|
1068
1149
|
};
|
|
1069
1150
|
/** @deprecated */
|
|
1070
1151
|
Geometry.DRAW_MODE = {
|
|
1071
|
-
POINTS:
|
|
1152
|
+
POINTS: import_constants2.default.POINTS,
|
|
1072
1153
|
// draw single points.
|
|
1073
|
-
LINES:
|
|
1154
|
+
LINES: import_constants2.default.LINES,
|
|
1074
1155
|
// draw lines. Each vertex connects to the one after it.
|
|
1075
|
-
LINE_LOOP:
|
|
1156
|
+
LINE_LOOP: import_constants2.default.LINE_LOOP,
|
|
1076
1157
|
// draw lines. Each set of two vertices is treated as a separate line segment.
|
|
1077
|
-
LINE_STRIP:
|
|
1158
|
+
LINE_STRIP: import_constants2.default.LINE_STRIP,
|
|
1078
1159
|
// draw a connected group of line segments from the first vertex to the last
|
|
1079
|
-
TRIANGLES:
|
|
1160
|
+
TRIANGLES: import_constants2.default.TRIANGLES,
|
|
1080
1161
|
// draw triangles. Each set of three vertices creates a separate triangle.
|
|
1081
|
-
TRIANGLE_STRIP:
|
|
1162
|
+
TRIANGLE_STRIP: import_constants2.default.TRIANGLE_STRIP,
|
|
1082
1163
|
// draw a connected group of triangles.
|
|
1083
|
-
TRIANGLE_FAN:
|
|
1164
|
+
TRIANGLE_FAN: import_constants2.default.TRIANGLE_FAN
|
|
1084
1165
|
// draw a connected group of triangles.
|
|
1085
1166
|
};
|
|
1086
1167
|
function convertToTopology(drawMode) {
|
|
1087
1168
|
switch (drawMode) {
|
|
1088
|
-
case
|
|
1169
|
+
case import_constants2.default.POINTS:
|
|
1089
1170
|
return "point-list";
|
|
1090
|
-
case
|
|
1171
|
+
case import_constants2.default.LINES:
|
|
1091
1172
|
return "line-list";
|
|
1092
|
-
case
|
|
1173
|
+
case import_constants2.default.LINE_STRIP:
|
|
1093
1174
|
return "line-strip";
|
|
1094
|
-
case
|
|
1175
|
+
case import_constants2.default.TRIANGLES:
|
|
1095
1176
|
return "triangle-list";
|
|
1096
|
-
case
|
|
1177
|
+
case import_constants2.default.TRIANGLE_STRIP:
|
|
1097
1178
|
return "triangle-strip";
|
|
1098
|
-
case
|
|
1179
|
+
case import_constants2.default.TRIANGLE_FAN:
|
|
1099
1180
|
return "triangle-fan";
|
|
1100
|
-
case
|
|
1181
|
+
case import_constants2.default.LINE_LOOP:
|
|
1101
1182
|
return "line-loop";
|
|
1102
1183
|
default:
|
|
1103
1184
|
throw new Error(String(drawMode));
|
|
@@ -1126,12 +1207,12 @@ var ClipSpace = class extends Model {
|
|
|
1126
1207
|
constructor(device, opts) {
|
|
1127
1208
|
const TEX_COORDS = POSITIONS.map((coord) => coord === -1 ? 0 : coord);
|
|
1128
1209
|
super(
|
|
1129
|
-
|
|
1210
|
+
import_webgl2.WebGLDevice.attach(device),
|
|
1130
1211
|
__spreadProps(__spreadValues({}, opts), {
|
|
1131
1212
|
vs: CLIPSPACE_VERTEX_SHADER,
|
|
1132
1213
|
vertexCount: 4,
|
|
1133
1214
|
geometry: new Geometry({
|
|
1134
|
-
drawMode:
|
|
1215
|
+
drawMode: import_constants3.default.TRIANGLE_STRIP,
|
|
1135
1216
|
vertexCount: 4,
|
|
1136
1217
|
attributes: {
|
|
1137
1218
|
aClipSpacePosition: { size: 2, value: new Float32Array(POSITIONS) },
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ export type { AnimationLoopProps } from './animation-loop/animation-loop';
|
|
|
6
6
|
export { AnimationLoop } from './animation-loop/animation-loop';
|
|
7
7
|
export type { MakeAnimationLoopProps } from './animation-loop/make-animation-loop';
|
|
8
8
|
export { makeAnimationLoop } from './animation-loop/make-animation-loop';
|
|
9
|
-
export type { ModelProps } from './
|
|
10
|
-
export { Model } from './
|
|
9
|
+
export type { ModelProps } from './model/model';
|
|
10
|
+
export { Model } from './model/model';
|
|
11
|
+
export { Transform } from './transform/transform';
|
|
11
12
|
export { PipelineFactory } from './lib/pipeline-factory';
|
|
12
13
|
export { ClipSpace } from './lib/clip-space';
|
|
13
14
|
export { Geometry } from './geometry/geometry';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAC,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAEnE,YAAY,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAE9D,YAAY,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AAEvE,YAAY,EAAC,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","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B,CAAC;AACpE,OAAO,EAAC,aAAa,EAAC,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAC5D,YAAY,EAAC,0BAA0B,EAAC,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAC,qBAAqB,EAAC,MAAM,sCAAsC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ export { KeyFrames } from "./animation/key-frames.js";
|
|
|
3
3
|
export { AnimationLoopTemplate } from "./animation-loop/render-loop.js";
|
|
4
4
|
export { AnimationLoop } from "./animation-loop/animation-loop.js";
|
|
5
5
|
export { makeAnimationLoop } from "./animation-loop/make-animation-loop.js";
|
|
6
|
-
export { Model } from "./
|
|
6
|
+
export { Model } from "./model/model.js";
|
|
7
|
+
export { Transform } from "./transform/transform.js";
|
|
7
8
|
export { PipelineFactory } from "./lib/pipeline-factory.js";
|
|
8
9
|
export { ClipSpace } from "./lib/clip-space.js";
|
|
9
10
|
export { Geometry } from "./geometry/geometry.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","PipelineFactory","ClipSpace","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry"],"sources":["../src/index.ts"],"sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/render-loop';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './
|
|
1
|
+
{"version":3,"file":"index.js","names":["Timeline","KeyFrames","AnimationLoopTemplate","AnimationLoop","makeAnimationLoop","Model","Transform","PipelineFactory","ClipSpace","Geometry","ConeGeometry","CubeGeometry","CylinderGeometry","IcoSphereGeometry","PlaneGeometry","SphereGeometry","TruncatedConeGeometry"],"sources":["../src/index.ts"],"sourcesContent":["// luma.gl Engine API\n\n// Animation\nexport {Timeline} from './animation/timeline';\nexport {KeyFrames} from './animation/key-frames';\nexport type {AnimationProps} from './animation-loop/animation-props';\n\nexport {AnimationLoopTemplate} from './animation-loop/render-loop';\n\nexport type {AnimationLoopProps} from './animation-loop/animation-loop';\nexport {AnimationLoop} from './animation-loop/animation-loop';\n\nexport type {MakeAnimationLoopProps} from './animation-loop/make-animation-loop';\nexport {makeAnimationLoop} from './animation-loop/make-animation-loop';\n\nexport type {ModelProps} from './model/model';\nexport {Model} from './model/model';\n\nexport {Transform} from './transform/transform';\n\nexport {PipelineFactory} from './lib/pipeline-factory';\n\n// Utils\nexport {ClipSpace} from './lib/clip-space';\n\n// Geometries\nexport {Geometry} from './geometry/geometry';\n\n// Primitives\nexport type {ConeGeometryProps} from './geometries/cone-geometry';\nexport {ConeGeometry} from './geometries/cone-geometry';\nexport type {CubeGeometryProps} from './geometries/cube-geometry';\nexport {CubeGeometry} from './geometries/cube-geometry';\nexport type {CylinderGeometryProps} from './geometries/cylinder-geometry';\nexport {CylinderGeometry} from './geometries/cylinder-geometry';\nexport type {IcoSphereGeometryProps} from './geometries/ico-sphere-geometry';\nexport {IcoSphereGeometry} from './geometries/ico-sphere-geometry';\nexport type {PlaneGeometryProps} from './geometries/plane-geometry';\nexport {PlaneGeometry} from './geometries/plane-geometry';\nexport type {SphereGeometryProps} from './geometries/sphere-geometry';\nexport {SphereGeometry} from './geometries/sphere-geometry';\nexport type {TruncatedConeGeometryProps} from './geometries/truncated-cone-geometry';\nexport {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';\n\n"],"mappings":"SAGQA,QAAQ;AAAA,SACRC,SAAS;AAAA,SAGTC,qBAAqB;AAAA,SAGrBC,aAAa;AAAA,SAGbC,iBAAiB;AAAA,SAGjBC,KAAK;AAAA,SAELC,SAAS;AAAA,SAETC,eAAe;AAAA,SAGfC,SAAS;AAAA,SAGTC,QAAQ;AAAA,SAIRC,YAAY;AAAA,SAEZC,YAAY;AAAA,SAEZC,gBAAgB;AAAA,SAEhBC,iBAAiB;AAAA,SAEjBC,aAAa;AAAA,SAEbC,cAAc;AAAA,SAEdC,qBAAqB"}
|
package/dist/lib/clip-space.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAO,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"clip-space.d.ts","sourceRoot":"","sources":["../../src/lib/clip-space.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAO,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAuBjD;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,MAAM,EAAE,MAAM,GAAG,qBAAqB,EAAE,IAAI,CAAC,EAAE,UAAU;CAqBtE"}
|
package/dist/lib/clip-space.js
CHANGED
|
@@ -3,7 +3,7 @@ var _templateObject;
|
|
|
3
3
|
import GL from '@luma.gl/constants';
|
|
4
4
|
import { glsl } from '@luma.gl/api';
|
|
5
5
|
import { WebGLDevice } from '@luma.gl/webgl';
|
|
6
|
-
import { Model } from "
|
|
6
|
+
import { Model } from "../model/model.js";
|
|
7
7
|
import { Geometry } from "../geometry/geometry.js";
|
|
8
8
|
const CLIPSPACE_VERTEX_SHADER = glsl(_templateObject || (_templateObject = _taggedTemplateLiteral(["attribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n"], ["\\\nattribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n"])));
|
|
9
9
|
const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-space.js","names":["GL","glsl","WebGLDevice","Model","Geometry","CLIPSPACE_VERTEX_SHADER","_templateObject","_taggedTemplateLiteral","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","attach","vs","vertexCount","geometry","drawMode","TRIANGLE_STRIP","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport GL from '@luma.gl/constants';\nimport {Device, glsl} from '@luma.gl/api';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {Model, ModelProps} from '
|
|
1
|
+
{"version":3,"file":"clip-space.js","names":["GL","glsl","WebGLDevice","Model","Geometry","CLIPSPACE_VERTEX_SHADER","_templateObject","_taggedTemplateLiteral","POSITIONS","ClipSpace","constructor","device","opts","TEX_COORDS","map","coord","attach","vs","vertexCount","geometry","drawMode","TRIANGLE_STRIP","attributes","aClipSpacePosition","size","value","Float32Array","aTexCoord","aCoordinate"],"sources":["../../src/lib/clip-space.ts"],"sourcesContent":["\n// ClipSpace\nimport GL from '@luma.gl/constants';\nimport {Device, glsl} from '@luma.gl/api';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {Model, ModelProps} from '../model/model';\nimport {Geometry} from '../geometry/geometry';\n\nconst CLIPSPACE_VERTEX_SHADER = glsl`\\\nattribute vec2 aClipSpacePosition;\nattribute vec2 aTexCoord;\nattribute vec2 aCoordinate;\n\nvarying vec2 position;\nvarying vec2 coordinate;\nvarying vec2 uv;\n\nvoid main(void) {\n gl_Position = vec4(aClipSpacePosition, 0., 1.);\n position = aClipSpacePosition;\n coordinate = aCoordinate;\n uv = aTexCoord;\n}\n`;\n\n/* eslint-disable indent, no-multi-spaces */\nconst POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];\n\n/**\n * A flat geometry that covers the \"visible area\" that the GPU renders.\n */\nexport class ClipSpace extends Model {\n constructor(device: Device | WebGLRenderingContext, opts?: ModelProps) {\n const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));\n\n super(\n WebGLDevice.attach(device),\n {\n ...opts,\n vs: CLIPSPACE_VERTEX_SHADER,\n vertexCount: 4,\n geometry: new Geometry({\n drawMode: GL.TRIANGLE_STRIP,\n vertexCount: 4,\n attributes: {\n aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},\n aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},\n aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}\n }\n })\n }\n );\n }\n}\n"],"mappings":";;AAEA,OAAOA,EAAE,MAAM,oBAAoB;AACnC,SAAgBC,IAAI,QAAO,cAAc;AACzC,SAAQC,WAAW,QAAO,gBAAgB;AAAC,SACnCC,KAAK;AAAA,SACLC,QAAQ;AAEhB,MAAMC,uBAAuB,GAAGJ,IAAI,CAAAK,eAAA,KAAAA,eAAA,GAAAC,sBAAA,gpBAenC;AAGD,MAAMC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAK9C,OAAO,MAAMC,SAAS,SAASN,KAAK,CAAC;EACnCO,WAAWA,CAACC,MAAsC,EAAEC,IAAiB,EAAE;IACrE,MAAMC,UAAU,GAAGL,SAAS,CAACM,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAGA,KAAM,CAAC;IAEvE,KAAK,CACHb,WAAW,CAACc,MAAM,CAACL,MAAM,CAAC,EAC1B;MACE,GAAGC,IAAI;MACPK,EAAE,EAAEZ,uBAAuB;MAC3Ba,WAAW,EAAE,CAAC;MACdC,QAAQ,EAAE,IAAIf,QAAQ,CAAC;QACrBgB,QAAQ,EAAEpB,EAAE,CAACqB,cAAc;QAC3BH,WAAW,EAAE,CAAC;QACdI,UAAU,EAAE;UACVC,kBAAkB,EAAE;YAACC,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAAClB,SAAS;UAAC,CAAC;UACjEmB,SAAS,EAAE;YAACH,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACb,UAAU;UAAC,CAAC;UACzDe,WAAW,EAAE;YAACJ,IAAI,EAAE,CAAC;YAAEC,KAAK,EAAE,IAAIC,YAAY,CAACb,UAAU;UAAC;QAC5D;MACF,CAAC;IACH,CAAC,CACF;EACH;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RenderPipelineParameters, PrimitiveTopology, ShaderLayout } from '@luma.gl/api';
|
|
2
|
-
import { Device, RenderPipeline } from '@luma.gl/api
|
|
2
|
+
import { Device, RenderPipeline } from '@luma.gl/api';
|
|
3
3
|
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
4
|
export declare type GetRenderPipelineOptions = {
|
|
5
5
|
vs: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"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E,cAAc,CAAC;QACzB,WAAW,EAAE,eAAe,CAAA;KAC7B;IAqBD,qEAAqE;IACrE,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM;IAiC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAQ7B,cAAc,CAAC,UAAU,GAAE,YAAY,EAAO,GAAG,YAAY,EAAE;CAyBhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.js","names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","_defineProperty","addDefaultModule","module","_defaultModules","find","m","name","push","stateHash","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","pipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","String","parameterHash","JSON","stringify","concat","join","_hashes","undefined","_hashCounter","appModules","arguments","length","Array","seen","count","i","len"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';\nimport {Device, RenderPipeline} from '@luma.gl/api/';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook: string, opts?: any): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = {}, inject = {}, parameters = {}} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(String(defines[key])));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"mappings":";AAGA,SAAQA,eAAe,QAAO,sBAAsB;AA+BpD,MAAMC,+BAAmE,GAAG;EAC1EC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,OAAO,EAAE,EAAE;EACXC,OAAO,EAAE,CAAC,CAAC;EACXC,M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C1B;EAGAnC,cAAcA,CAAA,EAAkD;IAAA,IAAjD6C,UAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAH,SAAA,GAAAG,SAAA,MAAG,EAAE;IAC5C,MAAMjF,OAAO,GAAG,IAAImF,KAAK,CAAC,IAAI,CAAClE,eAAe,CAACiE,MAAM,GAAGF,UAAU,CAACE,MAAM,CAAC;IAC1E,MAAME,IAA6B,GAAG,CAAC,CAAC;IACxC,IAAIC,KAAK,GAAG,CAAC;IAEb,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAG,IAAI,CAACtE,eAAe,CAACiE,MAAM,EAAEI,CAAC,GAAGC,GAAG,EAAE,EAAED,CAAC,EAAE;MAC/D,MAAMtE,MAAM,GAAG,IAAI,CAACC,eAAe,CAACqE,CAAC,CAAC;MACtC,MAAMlE,IAAI,GAAGJ,MAAM,CAACI,IAAI;MACxBpB,OAAO,CAACqF,KAAK,EAAE,CAAC,GAAGrE,MAAM;MACzBoE,IAAI,CAAChE,IAAI,CAAC,GAAG,IAAI;IACnB;IAEA,KAAK,IAAIkE,CAAC,GAAG,CAAC,EAAEC,GAAG,GAAGP,UAAU,CAACE,MAAM,EAAEI,CAAC,GAAGC,GAAG,EAAE,EAAED,CAAC,EAAE;MACrD,MAAMtE,MAAM,GAAGgE,UAAU,CAACM,CAAC,CAAC;MAC5B,MAAMlE,IAAI,GAAGJ,MAAM,CAACI,IAAI;MACxB,IAAI,CAACgE,IAAI,CAAChE,IAAI,CAAC,EAAE;QACfpB,OAAO,CAACqF,KAAK,EAAE,CAAC,GAAGrE,MAAM;QACzBoE,IAAI,CAAChE,IAAI,CAAC,GAAG,IAAI;MACnB;IACF;IAEApB,OAAO,CAACkF,MAAM,GAAGG,KAAK;IAEtB,OAAOrF,OAAO;EAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"pipeline-factory.js","names":["assembleShaders","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","getDefaultPipelineFactory","device","defaultPipelineFactory","constructor","_defineProperty","addDefaultModule","module","_defaultModules","find","m","name","push","stateHash","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","pipeline","getUniforms","_createRenderPipeline","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","hookFunctions","createShader","stage","source","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","String","parameterHash","JSON","stringify","concat","join","_hashes","undefined","_hashCounter","appModules","arguments","length","Array","seen","count","i","len"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';\nimport {Device, RenderPipeline} from '@luma.gl/api';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook: string, opts?: any): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = {}, inject = {}, parameters = {}} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(String(defines[key])));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"mappings":";AAGA,SAAQA,eAAe,QAAO,sBAAsB;AA+BpD,MAAMC,+BAAmE,GAAG;EAC1EC,EAAE,EAAE,EAAE;EACNC,EAAE,EAAE,EAAE;EACNC,OAAO,EAAE,EAAE;EACXC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC,CAAC;EACVC,kBAAkB,EAAE,KAAK;EACzBC,MAAM,EAAE,IAAI;EAEZC,QAAQ,EAAE,EAAE;EACZC,UAAU,EAAE,MAAM;EAClBC,QAAQ,EAAE,eAAe;EACzBC,UAAU,EAAE,CAAC;AACf,CAAC;AAKD,OAAO,MAAMC,eAAe,CAAC;EAe3B,OAAOC,yBAAyBA,CAACC,MAAc,EAAmB;IAEhEA,MAAM,CAACC,sBAAsB,GAAGD,MAAM,CAACC,sBAAsB,IAAI,IAAIH,eAAe,CAACE,MAAM,CAAC;IAE5F,O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@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-utils.js","names":["Buffer","assert","GLTF_TO_LUMA_ATTRIBUTE_MAP","POSITION","NORMAL","COLOR_0","TEXCOORD_0","TEXCOORD_1","TEXCOORD_2","getIndexBufferFromGeometry","device","geometry","indices","undefined","data","value","Uint16Array","Uint32Array","createBuffer","usage","INDEX","getAttributeBuffersFromGeometry","buffers","name","attribute","Object","entries","attributes","remappedName","mapAttributeName","constant","Error","typedArray","id","concat"],"sources":["../../src/model/model-utils.ts"],"sourcesContent":["import {Device, Buffer, assert} from '@luma.gl/api';\nimport type {Geometry} from '../geometry/geometry';\n\n// Support for mapping new geometries with glTF attribute names to \"classic\" luma.gl shader names\nconst GLTF_TO_LUMA_ATTRIBUTE_MAP = {\n POSITION: 'positions',\n NORMAL: 'normals',\n COLOR_0: 'colors',\n TEXCOORD_0: 'texCoords',\n TEXCOORD_1: 'texCoords1',\n TEXCOORD_2: 'texCoords2'\n};\n\n/*\nexport function getAttributeLayoutsFromGeometry(geometry: Geometry) {\n const layouts: Record<string, {}> = {};\n let indices = geometry.indices;\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n\n if (attribute.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute.value;\n // Create accessor by copying the attribute and removing `value``\n const accessor = {...attribute};\n delete accessor.value;\n buffers[remappedName] = [device.createBuffer(typedArray), accessor];\n\n inferAttributeAccessor(name, accessor);\n }\n }\n}\n\nexport class Table {\n length: number;\n // columns: Record<string, TypedArray> = {};\n}\n\nexport class GPUTable {\n length: number;\n columns: Record<string, Buffer> = {};\n}\n\nexport function convertTableToGPUTable(table: Table) {\n // for (const ) {}\n}\n\nexport function renameTableColumns(table: Table, map: (name: string) => string) {\n const newColumns = table.columns.reduce()\n table.clone();\n}\n*/\n\nexport function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined {\n if (!geometry.indices) {\n return undefined;\n }\n\n // @ts-expect-error\n const data = geometry.indices.value || geometry.indices;\n assert(\n data instanceof Uint16Array || data instanceof Uint32Array,\n 'attribute array for \"indices\" must be of integer type'\n );\n return device.createBuffer({usage: Buffer.INDEX, data});\n}\n\nexport function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer> {\n const buffers: Record<string, Buffer> = {};\n\n for (const [name, attribute] of Object.entries(geometry.attributes)) {\n const remappedName = mapAttributeName(name);\n if (attribute?.constant) {\n throw new Error('constant attributes not supported');\n } else {\n const typedArray = attribute?.value;\n buffers[remappedName] = device.createBuffer({data: typedArray, id: `${remappedName}-buffer`});\n }\n }\n\n return buffers;\n}\n\nfunction mapAttributeName(name: string): string {\n // @ts-ignore-error\n return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;\n}\n\n/*\n// Check for well known attribute names\n// eslint-disable-next-line complexity\nexport function inferAttributeAccessor(attributeName, attribute) {\n let category;\n switch (attributeName) {\n case 'texCoords':\n case 'texCoord1':\n case 'texCoord2':\n case 'texCoord3':\n category = 'uvs';\n break;\n case 'vertices':\n case 'positions':\n case 'normals':\n case 'pickingColors':\n category = 'vectors';\n break;\n default:\n }\n\n // Check for categorys\n switch (category) {\n case 'vectors':\n attribute.size = attribute.size || 3;\n break;\n case 'uvs':\n attribute.size = attribute.size || 2;\n break;\n default:\n }\n\n assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);\n}\n*/\n"],"mappings":"AAAA,SAAgBA,MAAM,EAAEC,MAAM,QAAO,cAAc;AAInD,MAAMC,0BAA0B,GAAG;EACjCC,QAAQ,EAAE,WAAW;EACrBC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAE,QAAQ;EACjBC,UAAU,EAAE,WAAW;EACvBC,UAAU,EAAE,YAAY;EACxBC,UAAU,EAAE;AACd,CAAC;AA4CD,OAAO,SAASC,0BAA0BA,CAACC,MAAc,EAAEC,QAAkB,EAAsB;EACjG,IAAI,CAACA,QAAQ,CAACC,OAAO,EAAE;IACrB,OAAOC,SAAS;EAClB;EAGA,MAAMC,IAAI,GAAGH,QAAQ,CAACC,OAAO,CAACG,KAAK,IAAIJ,QAAQ,CAACC,OAAO;EACvDX,MAAM,CACJa,IAAI,YAAYE,WAAW,IAAIF,IAAI,YAAYG,WAAW,EAC1D,uDAAuD,CACxD;EACD,OAAOP,MAAM,CAACQ,YAAY,CAAC;IAACC,KAAK,EAAEnB,MAAM,CAACoB,KAAK;IAAEN;EAAI,CAAC,CAAC;AACzD;AAEA,OAAO,SAASO,+BAA+BA,CAACX,MAAc,EAAEC,QAAkB,EAA0B;EAC1G,MAAMW,OAA+B,GAAG,CAAC,CAAC;EAE1C,KAAK,MAAM,CAACC,IAAI,EAAEC,SAAS,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACf,QAAQ,CAACgB,UAAU,CAAC,EAAE;IACnE,MAAMC,YAAY,GAAGC,gBAAgB,CAACN,IAAI,CAAC;IAC3C,IAAIC,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEM,QAAQ,EAAE;MACvB,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;IACtD,CAAC,MAAM;MACL,MAAMC,UAAU,GAAGR,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAET,KAAK;MACnCO,OAAO,CAACM,YAAY,CAAC,GAAGlB,MAAM,CAACQ,YAAY,CAAC;QAACJ,IAAI,EAAEkB,UAAU;QAAEC,EAAE,KAAAC,MAAA,CAAKN,YAAY;MAAS,CAAC,CAAC;IAC/F;EACF;EAEA,OAAON,OAAO;AAChB;AAEA,SAASO,gBAAgBA,CAACN,IAAY,EAAU;EAE9C,OAAOrB,0BAA0B,CAACqB,IAAI,CAAC,IAAIA,IAAI;AACjD"}
|
|
@@ -2,6 +2,7 @@ import type { Device, Buffer, RenderPipelineProps, RenderPass, Binding, Primitiv
|
|
|
2
2
|
import { RenderPipeline } from '@luma.gl/api';
|
|
3
3
|
import type { ShaderModule } from '@luma.gl/shadertools';
|
|
4
4
|
import type { Geometry } from '../geometry/geometry';
|
|
5
|
+
import { PipelineFactory } from '../lib/pipeline-factory';
|
|
5
6
|
export declare type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
6
7
|
vs?: {
|
|
7
8
|
glsl?: string;
|
|
@@ -11,24 +12,28 @@ export declare type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
11
12
|
glsl?: string;
|
|
12
13
|
wgsl?: string;
|
|
13
14
|
} | string | null;
|
|
15
|
+
defines?: Record<string, string | number | boolean>;
|
|
14
16
|
modules?: ShaderModule[];
|
|
15
17
|
moduleSettings?: Record<string, Record<string, any>>;
|
|
16
18
|
geometry?: Geometry | null;
|
|
19
|
+
/** deprecated pipeline factory to use to create renderpipelines */
|
|
20
|
+
pipelineFactory?: PipelineFactory;
|
|
17
21
|
};
|
|
18
22
|
/** v9 API */
|
|
19
23
|
export declare class Model {
|
|
20
24
|
readonly device: Device;
|
|
21
|
-
readonly pipeline: RenderPipeline;
|
|
22
25
|
readonly id: string;
|
|
23
26
|
readonly vs: string;
|
|
24
27
|
readonly fs: string | null;
|
|
25
28
|
readonly topology: PrimitiveTopology;
|
|
26
29
|
readonly vertexCount: number;
|
|
30
|
+
readonly pipelineFactory: PipelineFactory;
|
|
31
|
+
pipeline: RenderPipeline;
|
|
27
32
|
props: Required<ModelProps>;
|
|
28
33
|
private _getModuleUniforms;
|
|
29
34
|
constructor(device: Device, props: ModelProps);
|
|
30
35
|
destroy(): void;
|
|
31
|
-
draw(renderPass
|
|
36
|
+
draw(renderPass: RenderPass): this;
|
|
32
37
|
setProps(props: ModelProps): this;
|
|
33
38
|
updateModuleSettings(props: Record<string, any>): this;
|
|
34
39
|
setIndexBuffer(indices: Buffer): this;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,E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;IACrC,QAAQ,CAAC,WAAW,SAAC;IAErB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,EAAE,cAAc,CAAC;IAEzB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAE5B,OAAO,CAAC,kBAAkB,CAAuE;gBAErF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IA4C7C,OAAO,IAAI,IAAI;IAIf,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IASlC,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAmBjC,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAMtD,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMrC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAMvD,uBAAuB;IACvB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAMpD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAMhD,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAWvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { RenderPipeline } from '@luma.gl/api';
|
|
3
3
|
import { getAttributeBuffersFromGeometry, getIndexBufferFromGeometry } from "./model-utils.js";
|
|
4
|
-
import { PipelineFactory } from "
|
|
4
|
+
import { PipelineFactory } from "../lib/pipeline-factory.js";
|
|
5
5
|
const DEFAULT_MODEL_PROPS = {
|
|
6
6
|
...RenderPipeline._DEFAULT_PROPS,
|
|
7
7
|
vs: null,
|
|
@@ -9,19 +9,22 @@ const DEFAULT_MODEL_PROPS = {
|
|
|
9
9
|
id: 'unnamed',
|
|
10
10
|
handle: undefined,
|
|
11
11
|
userData: {},
|
|
12
|
+
defines: {},
|
|
12
13
|
modules: [],
|
|
13
14
|
moduleSettings: {},
|
|
14
|
-
geometry: null
|
|
15
|
+
geometry: null,
|
|
16
|
+
pipelineFactory: undefined
|
|
15
17
|
};
|
|
16
18
|
export class Model {
|
|
17
19
|
constructor(device, props) {
|
|
18
20
|
_defineProperty(this, "device", void 0);
|
|
19
|
-
_defineProperty(this, "pipeline", void 0);
|
|
20
21
|
_defineProperty(this, "id", void 0);
|
|
21
22
|
_defineProperty(this, "vs", void 0);
|
|
22
23
|
_defineProperty(this, "fs", null);
|
|
23
24
|
_defineProperty(this, "topology", void 0);
|
|
24
25
|
_defineProperty(this, "vertexCount", void 0);
|
|
26
|
+
_defineProperty(this, "pipelineFactory", void 0);
|
|
27
|
+
_defineProperty(this, "pipeline", void 0);
|
|
25
28
|
_defineProperty(this, "props", void 0);
|
|
26
29
|
_defineProperty(this, "_getModuleUniforms", void 0);
|
|
27
30
|
this.props = {
|
|
@@ -44,15 +47,16 @@ export class Model {
|
|
|
44
47
|
this.vertexCount = this.props.geometry.vertexCount;
|
|
45
48
|
this.topology = this.props.geometry.topology || 'triangle-list';
|
|
46
49
|
}
|
|
47
|
-
|
|
50
|
+
this.pipelineFactory = this.props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);
|
|
48
51
|
const {
|
|
49
52
|
pipeline,
|
|
50
53
|
getUniforms
|
|
51
|
-
} = pipelineFactory.createRenderPipeline({
|
|
54
|
+
} = this.pipelineFactory.createRenderPipeline({
|
|
52
55
|
...this.props,
|
|
53
56
|
vs: this.vs,
|
|
54
57
|
fs: this.fs,
|
|
55
58
|
topology: this.topology,
|
|
59
|
+
defines: props.defines,
|
|
56
60
|
parameters: props.parameters,
|
|
57
61
|
layout: props.layout
|
|
58
62
|
});
|
|
@@ -65,7 +69,7 @@ export class Model {
|
|
|
65
69
|
this.setProps(this.props);
|
|
66
70
|
}
|
|
67
71
|
destroy() {
|
|
68
|
-
this.
|
|
72
|
+
this.pipelineFactory.release(this.pipeline);
|
|
69
73
|
}
|
|
70
74
|
draw(renderPass) {
|
|
71
75
|
this.pipeline.draw({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","names":["RenderPipeline","getAttributeBuffersFromGeometry","getIndexBufferFromGeometry","PipelineFactory","DEFAULT_MODEL_PROPS","_DEFAULT_PROPS","vs","fs","id","handle","undefined","userData","defines","modules","moduleSettings","geometry","pipelineFactory","Model","constructor","device","props","_defineProperty","Error","getShaderSource","vertexCount","topology","getDefaultPipelineFactory","pipeline","getUniforms","createRenderPipeline","parameters","layout","_getModuleUniforms","_setGeometry","setUniforms","setProps","destroy","release","draw","renderPass","instanceCount","indices","setIndexBuffer","attributes","setAttributes","bindings","setBindings","uniforms","updateModuleSettings","Object","assign","geometryBuffers","indexBuffer","shader","info","type","wgsl","glsl"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, Buffer, RenderPipelineProps, RenderPass, Binding, PrimitiveTopology} from '@luma.gl/api';\nimport {RenderPipeline} from '@luma.gl/api';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport type {Geometry} from '../geometry/geometry';\nimport {getAttributeBuffersFromGeometry, getIndexBufferFromGeometry} from './model-utils';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string\n vs?: {glsl?: string; wgsl?: string} | string | null;\n fs?: {glsl?: string; wgsl?: string} | string | null;\n defines?: Record<string, string | number | boolean>;\n modules?: ShaderModule[];\n moduleSettings?: Record<string, Record<string, any>>;\n geometry?: Geometry | null;\n /** deprecated pipeline factory to use to create renderpipelines */\n pipelineFactory?: PipelineFactory;\n};\n\nconst DEFAULT_MODEL_PROPS: Required<ModelProps> = {\n ...RenderPipeline._DEFAULT_PROPS,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: {},\n geometry: null,\n pipelineFactory: undefined\n};\n\n/** v9 API */\nexport class Model {\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string | null = null;\n readonly topology: PrimitiveTopology;\n readonly vertexCount;\n\n readonly pipelineFactory: PipelineFactory;\n pipeline: RenderPipeline;\n\n props: Required<ModelProps>;\n\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...DEFAULT_MODEL_PROPS, ...props};\n props = this.props;\n this.id = this.props.id;\n this.device = device;\n\n // Create the pipeline\n if (!props.vs) {\n throw new Error('no vertex shader');\n }\n this.vs = getShaderSource(this.device, props.vs);\n if (props.fs) {\n this.fs = getShaderSource(this.device, props.fs);\n }\n\n this.vertexCount = this.props.vertexCount;\n this.topology = this.props.topology;\n\n if (this.props.geometry) {\n this.vertexCount = this.props.geometry.vertexCount;\n this.topology = this.props.geometry.topology || 'triangle-list';\n }\n\n this.pipelineFactory = this.props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n const {pipeline, getUniforms} = this.pipelineFactory.createRenderPipeline({\n ...this.props,\n vs: this.vs,\n fs: this.fs,\n topology: this.topology,\n defines: props.defines,\n parameters: props.parameters,\n layout: props.layout\n });\n\n this.pipeline = pipeline;\n this._getModuleUniforms = getUniforms;\n\n if (this.props.geometry) {\n this._setGeometry(this.props.geometry);\n }\n this.setUniforms(this._getModuleUniforms()) // Get all default module uniforms\n this.setProps(this.props);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n }\n\n draw(renderPass: RenderPass): this {\n this.pipeline.draw({\n renderPass,\n vertexCount: this.vertexCount,\n instanceCount: this.props.instanceCount\n });\n return this;\n }\n\n setProps(props: ModelProps): this {\n if (props.indices) {\n this.setIndexBuffer(props.indices);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n return this;\n }\n\n updateModuleSettings(props: Record<string, any>): this {\n const uniforms = this._getModuleUniforms(props);\n this.setUniforms(uniforms);\n return this;\n }\n\n setIndexBuffer(indices: Buffer): this {\n this.pipeline.setIndexBuffer(indices);\n // this._indices = indices;\n return this;\n }\n\n setAttributes(attributes: Record<string, Buffer>): this {\n this.pipeline.setAttributes(attributes);\n Object.assign(this.props.attributes, attributes);\n return this;\n }\n\n /** Set the bindings */\n setBindings(bindings: Record<string, Binding>): this {\n this.pipeline.setBindings(bindings);\n Object.assign(this.props.bindings, bindings);\n return this;\n }\n\n setUniforms(uniforms: Record<string, any>): this {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.props.uniforms, uniforms);\n return this;\n }\n\n _setGeometry(geometry: Geometry): void {\n // this._deleteGeometryBuffers();\n\n const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);\n this.setAttributes(geometryBuffers);\n\n const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);\n if (indexBuffer) {\n this.setIndexBuffer(indexBuffer);\n }\n }\n}\n\n/** Create a shader from the different overloads */\nfunction getShaderSource(device: Device, shader: string | {glsl?: string; wgsl?: string}): string {\n // TODO - detect WGSL/GLSL and throw an error if not supported\n if (typeof shader === 'string') {\n return shader;\n }\n\n switch (device.info.type) {\n case 'webgpu':\n if (shader?.wgsl) {\n return shader.wgsl;\n }\n throw new Error('WebGPU does not support GLSL shaders');\n\n default:\n if (shader?.glsl) {\n return shader.glsl;\n }\n throw new Error('WebGL does not support WGSL shaders');\n }\n}\n"],"mappings":";AAGA,SAAQA,cAAc,QAAO,cAAc;AAAC,SAGpCC,+BAA+B,EAAEC,0BAA0B;AAAA,SAC3DC,eAAe;AAcvB,MAAMC,mBAAyC,GAAG;EAChD,GAAGJ,cAAc,CAACK,cAAc;EAChCC,EAAE,EAAE,IAAI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