@luma.gl/engine 9.0.0-alpha.30 → 9.0.0-alpha.32
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/dist.dev.js +1028 -685
- package/dist/geometries/truncated-cone-geometry.d.ts +0 -2
- package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
- package/dist/geometries/truncated-cone-geometry.js +0 -11
- package/dist/geometries/truncated-cone-geometry.js.map +1 -1
- package/dist/geometry/geometry.d.ts +6 -7
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +45 -0
- package/dist/geometry/gpu-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-geometry.js +123 -0
- package/dist/geometry/gpu-geometry.js.map +1 -0
- package/dist/geometry/gpu-table.d.ts +1 -0
- package/dist/geometry/gpu-table.d.ts.map +1 -0
- package/dist/geometry/gpu-table.js +2 -0
- package/dist/geometry/gpu-table.js.map +1 -0
- package/dist/index.cjs +311 -209
- package/dist/lib/pipeline-factory.d.ts +11 -44
- package/dist/lib/pipeline-factory.d.ts.map +1 -1
- package/dist/lib/pipeline-factory.js +28 -119
- package/dist/lib/pipeline-factory.js.map +1 -1
- package/dist/model/model-shaders.d.ts +35 -0
- package/dist/model/model-shaders.d.ts.map +1 -0
- package/dist/model/model-shaders.js +38 -0
- package/dist/model/model-shaders.js.map +1 -0
- package/dist/model/model-utils.d.ts +1 -1
- package/dist/model/model-utils.d.ts.map +1 -1
- package/dist/model/model-utils.js +1 -1
- package/dist/model/model-utils.js.map +1 -1
- package/dist/model/model.d.ts +110 -23
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +144 -91
- package/dist/model/model.js.map +1 -1
- package/dist.min.js +71 -71
- package/package.json +6 -6
- package/src/geometries/truncated-cone-geometry.ts +0 -10
- package/src/geometry/geometry.ts +7 -7
- package/src/geometry/gpu-geometry.ts +159 -0
- package/src/geometry/gpu-table.ts +41 -0
- package/src/lib/pipeline-factory.ts +43 -163
- package/src/model/model-shaders.ts +76 -0
- package/src/model/model-utils.ts +2 -2
- package/src/model/model.ts +271 -125
- package/dist/geometry/primitive-utils.d.ts +0 -1
- package/dist/geometry/primitive-utils.d.ts.map +0 -1
- package/dist/geometry/primitive-utils.js +0 -2
- package/dist/geometry/primitive-utils.js.map +0 -1
- package/src/geometry/primitive-utils.ts +0 -30
|
@@ -1,60 +1,27 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RenderPipelineProps } from '@luma.gl/core';
|
|
2
2
|
import { Device, RenderPipeline } from '@luma.gl/core';
|
|
3
|
-
|
|
4
|
-
export type
|
|
3
|
+
/** Todo - should be same as RenderPipelineProps */
|
|
4
|
+
export type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
5
5
|
vs: string;
|
|
6
|
-
fs: string
|
|
7
|
-
topology: PrimitiveTopology;
|
|
8
|
-
layout?: ShaderLayout | null;
|
|
9
|
-
parameters?: RenderPipelineParameters;
|
|
10
|
-
modules?: ShaderModule[];
|
|
11
|
-
defines?: Record<string, string | number | boolean>;
|
|
12
|
-
inject?: Record<string, string>;
|
|
13
|
-
transpileToGLSL100?: boolean;
|
|
14
|
-
varyings?: string[];
|
|
15
|
-
bufferMode?: number;
|
|
6
|
+
fs: string;
|
|
16
7
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
modules?: ShaderModule[];
|
|
21
|
-
defines?: Record<string, string>;
|
|
22
|
-
inject?: Record<string, string>;
|
|
23
|
-
transpileToGLSL100?: boolean;
|
|
24
|
-
varyings?: string[];
|
|
25
|
-
bufferMode?: number;
|
|
26
|
-
};
|
|
27
|
-
type GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;
|
|
28
|
-
/** Efficiently create shared pipelines with varying parameters */
|
|
8
|
+
/**
|
|
9
|
+
* Efficiently creates / caches pipelines
|
|
10
|
+
*/
|
|
29
11
|
export declare class PipelineFactory {
|
|
12
|
+
static defaultProps: Required<PipelineFactoryProps>;
|
|
30
13
|
readonly device: Device;
|
|
31
|
-
stateHash: number;
|
|
32
14
|
private _hashCounter;
|
|
33
15
|
private readonly _hashes;
|
|
34
16
|
private readonly _useCounts;
|
|
35
17
|
private readonly _pipelineCache;
|
|
36
|
-
private readonly _getUniforms;
|
|
37
|
-
private readonly _hookFunctions;
|
|
38
|
-
private _defaultModules;
|
|
39
18
|
static getDefaultPipelineFactory(device: Device): PipelineFactory;
|
|
40
19
|
constructor(device: Device);
|
|
41
|
-
|
|
42
|
-
removeDefaultModule(module: ShaderModule): void;
|
|
43
|
-
addShaderHook(hook: string, opts?: any): void;
|
|
44
|
-
createRenderPipeline(options: GetRenderPipelineOptions): {
|
|
45
|
-
pipeline: RenderPipeline;
|
|
46
|
-
getUniforms: GetUniformsFunc;
|
|
47
|
-
};
|
|
20
|
+
createRenderPipeline(options: PipelineFactoryProps): RenderPipeline;
|
|
48
21
|
release(pipeline: RenderPipeline): void;
|
|
49
|
-
|
|
50
|
-
_createRenderPipeline(props: GetRenderPipelineOptions): {
|
|
51
|
-
pipeline: RenderPipeline;
|
|
52
|
-
getUniforms: GetUniformsFunc;
|
|
53
|
-
};
|
|
22
|
+
_createRenderPipeline(props: PipelineFactoryProps): RenderPipeline;
|
|
54
23
|
/** Calculate a hash based on all the inputs for a render pipeline */
|
|
55
|
-
_hashRenderPipeline(props:
|
|
24
|
+
_hashRenderPipeline(props: PipelineFactoryProps): string;
|
|
56
25
|
_getHash(key: string): number;
|
|
57
|
-
_getModuleList(appModules?: ShaderModule[]): ShaderModule[];
|
|
58
26
|
}
|
|
59
|
-
export {};
|
|
60
27
|
//# sourceMappingURL=pipeline-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"pipeline-factory.d.ts","sourceRoot":"","sources":["../../src/lib/pipeline-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AACvD,OAAO,EAAC,MAAM,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAE1E,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAe;IAC1B,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAIlD;IAED,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE,MAAM,CAAC,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;gBAKrD,MAAM,EAAE,MAAM;IAI1B,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc;IAsBnE,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAYvC,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,cAAc;IAclE,qEAAqE;IACrE,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,MAAM;IAqBxD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAM9B"}
|
|
@@ -1,83 +1,44 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
3
|
-
const DEFAULT_RENDER_PIPELINE_OPTIONS = {
|
|
4
|
-
vs: '',
|
|
5
|
-
fs: '',
|
|
6
|
-
modules: [],
|
|
7
|
-
defines: {},
|
|
8
|
-
inject: {},
|
|
9
|
-
transpileToGLSL100: false,
|
|
10
|
-
layout: null,
|
|
11
|
-
varyings: [],
|
|
12
|
-
bufferMode: 0x8c8d,
|
|
13
|
-
topology: 'triangle-list',
|
|
14
|
-
parameters: {}
|
|
15
|
-
};
|
|
2
|
+
import { RenderPipeline } from '@luma.gl/core';
|
|
16
3
|
export class PipelineFactory {
|
|
17
4
|
static getDefaultPipelineFactory(device) {
|
|
18
|
-
device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
|
|
19
|
-
return device.defaultPipelineFactory;
|
|
5
|
+
device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);
|
|
6
|
+
return device._lumaData.defaultPipelineFactory;
|
|
20
7
|
}
|
|
21
8
|
constructor(device) {
|
|
22
9
|
_defineProperty(this, "device", void 0);
|
|
23
|
-
_defineProperty(this, "stateHash", 0);
|
|
24
10
|
_defineProperty(this, "_hashCounter", 0);
|
|
25
11
|
_defineProperty(this, "_hashes", {});
|
|
26
12
|
_defineProperty(this, "_useCounts", {});
|
|
27
13
|
_defineProperty(this, "_pipelineCache", {});
|
|
28
|
-
_defineProperty(this, "_getUniforms", {});
|
|
29
|
-
_defineProperty(this, "_hookFunctions", []);
|
|
30
|
-
_defineProperty(this, "_defaultModules", []);
|
|
31
14
|
this.device = device;
|
|
32
15
|
}
|
|
33
|
-
addDefaultModule(module) {
|
|
34
|
-
if (!this._defaultModules.find(m => m.name === (typeof module === 'string' ? module : module.name))) {
|
|
35
|
-
this._defaultModules.push(module);
|
|
36
|
-
}
|
|
37
|
-
this.stateHash++;
|
|
38
|
-
}
|
|
39
|
-
removeDefaultModule(module) {
|
|
40
|
-
const moduleName = typeof module === 'string' ? module : module.name;
|
|
41
|
-
this._defaultModules = this._defaultModules.filter(m => m.name !== moduleName);
|
|
42
|
-
this.stateHash++;
|
|
43
|
-
}
|
|
44
|
-
addShaderHook(hook, opts) {
|
|
45
|
-
if (opts) {
|
|
46
|
-
hook = Object.assign(opts, {
|
|
47
|
-
hook
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
this._hookFunctions.push(hook);
|
|
51
|
-
this.stateHash++;
|
|
52
|
-
}
|
|
53
16
|
createRenderPipeline(options) {
|
|
54
17
|
const props = {
|
|
55
|
-
...
|
|
18
|
+
...PipelineFactory.defaultProps,
|
|
56
19
|
...options
|
|
57
20
|
};
|
|
58
|
-
const modules = this._getModuleList(props.modules);
|
|
59
21
|
const hash = this._hashRenderPipeline({
|
|
60
|
-
...props
|
|
61
|
-
modules
|
|
22
|
+
...props
|
|
62
23
|
});
|
|
63
24
|
if (!this._pipelineCache[hash]) {
|
|
64
|
-
const {
|
|
65
|
-
pipeline,
|
|
66
|
-
getUniforms
|
|
67
|
-
} = this._createRenderPipeline({
|
|
25
|
+
const pipeline = this.device.createRenderPipeline({
|
|
68
26
|
...props,
|
|
69
|
-
|
|
27
|
+
vs: this.device.createShader({
|
|
28
|
+
stage: 'vertex',
|
|
29
|
+
source: props.vs
|
|
30
|
+
}),
|
|
31
|
+
fs: props.fs ? this.device.createShader({
|
|
32
|
+
stage: 'fragment',
|
|
33
|
+
source: props.fs
|
|
34
|
+
}) : null
|
|
70
35
|
});
|
|
71
36
|
pipeline.hash = hash;
|
|
72
37
|
this._pipelineCache[hash] = pipeline;
|
|
73
|
-
this._getUniforms[hash] = getUniforms || (x => ({}));
|
|
74
38
|
this._useCounts[hash] = 0;
|
|
75
39
|
}
|
|
76
40
|
this._useCounts[hash]++;
|
|
77
|
-
return
|
|
78
|
-
pipeline: this._pipelineCache[hash],
|
|
79
|
-
getUniforms: this._getUniforms[hash]
|
|
80
|
-
};
|
|
41
|
+
return this._pipelineCache[hash];
|
|
81
42
|
}
|
|
82
43
|
release(pipeline) {
|
|
83
44
|
const hash = pipeline.hash;
|
|
@@ -85,68 +46,33 @@ export class PipelineFactory {
|
|
|
85
46
|
if (this._useCounts[hash] === 0) {
|
|
86
47
|
this._pipelineCache[hash].destroy();
|
|
87
48
|
delete this._pipelineCache[hash];
|
|
88
|
-
delete this._getUniforms[hash];
|
|
89
49
|
delete this._useCounts[hash];
|
|
90
50
|
}
|
|
91
51
|
}
|
|
92
|
-
getUniforms(pipeline) {
|
|
93
|
-
return this._getUniforms[pipeline.hash] || null;
|
|
94
|
-
}
|
|
95
52
|
_createRenderPipeline(props) {
|
|
96
|
-
const platformInfo = {
|
|
97
|
-
gpu: this.device.info.gpu,
|
|
98
|
-
features: this.device.features
|
|
99
|
-
};
|
|
100
53
|
if (!props.fs) {
|
|
101
54
|
throw new Error('fs');
|
|
102
55
|
}
|
|
103
|
-
const assembled = assembleShaders(platformInfo, {
|
|
104
|
-
...props,
|
|
105
|
-
fs: props.fs,
|
|
106
|
-
hookFunctions: this._hookFunctions
|
|
107
|
-
});
|
|
108
56
|
const pipeline = this.device.createRenderPipeline({
|
|
109
57
|
...props,
|
|
110
58
|
vs: this.device.createShader({
|
|
111
59
|
stage: 'vertex',
|
|
112
|
-
source:
|
|
60
|
+
source: props.vs
|
|
113
61
|
}),
|
|
114
|
-
fs:
|
|
62
|
+
fs: props.fs ? this.device.createShader({
|
|
115
63
|
stage: 'fragment',
|
|
116
|
-
source:
|
|
64
|
+
source: props.fs
|
|
117
65
|
}) : null
|
|
118
66
|
});
|
|
119
|
-
return
|
|
120
|
-
pipeline,
|
|
121
|
-
getUniforms: assembled.getUniforms
|
|
122
|
-
};
|
|
67
|
+
return pipeline;
|
|
123
68
|
}
|
|
124
69
|
_hashRenderPipeline(props) {
|
|
125
|
-
const {
|
|
126
|
-
modules = [],
|
|
127
|
-
varyings = [],
|
|
128
|
-
defines = {},
|
|
129
|
-
inject = {},
|
|
130
|
-
parameters = {}
|
|
131
|
-
} = props;
|
|
132
70
|
const vsHash = this._getHash(props.vs);
|
|
133
71
|
const fsHash = props.fs ? this._getHash(props.fs) : 0;
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
const defineHashes = [];
|
|
139
|
-
const injectHashes = [];
|
|
140
|
-
for (const key of defineKeys) {
|
|
141
|
-
defineHashes.push(this._getHash(key));
|
|
142
|
-
defineHashes.push(this._getHash(String(defines[key])));
|
|
143
|
-
}
|
|
144
|
-
for (const key of injectKeys) {
|
|
145
|
-
injectHashes.push(this._getHash(key));
|
|
146
|
-
injectHashes.push(this._getHash(inject[key]));
|
|
147
|
-
}
|
|
148
|
-
const parameterHash = JSON.stringify(parameters);
|
|
149
|
-
return "".concat(vsHash, "/").concat(fsHash, "D").concat(defineHashes.join('/'), "M").concat(moduleHashes.join('/'), "I").concat(injectHashes.join('/'), "V").concat(varyingHashes.join('/'), "H").concat(this.stateHash, "B").concat(props.bufferMode).concat(props.transpileToGLSL100 ? 'T' : '', "P").concat(parameterHash);
|
|
72
|
+
const parameterHash = this._getHash(JSON.stringify(props.parameters));
|
|
73
|
+
const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));
|
|
74
|
+
const varyingHash = '-';
|
|
75
|
+
return "".concat(vsHash, "/").concat(fsHash, "V").concat(varyingHash, "T").concat(props.topology, "P").concat(parameterHash, "BL").concat(bufferLayoutHash, "}");
|
|
150
76
|
}
|
|
151
77
|
_getHash(key) {
|
|
152
78
|
if (this._hashes[key] === undefined) {
|
|
@@ -154,27 +80,10 @@ export class PipelineFactory {
|
|
|
154
80
|
}
|
|
155
81
|
return this._hashes[key];
|
|
156
82
|
}
|
|
157
|
-
_getModuleList() {
|
|
158
|
-
let appModules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
159
|
-
const modules = new Array(this._defaultModules.length + appModules.length);
|
|
160
|
-
const seen = {};
|
|
161
|
-
let count = 0;
|
|
162
|
-
for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
|
|
163
|
-
const module = this._defaultModules[i];
|
|
164
|
-
const name = module.name;
|
|
165
|
-
modules[count++] = module;
|
|
166
|
-
seen[name] = true;
|
|
167
|
-
}
|
|
168
|
-
for (let i = 0, len = appModules.length; i < len; ++i) {
|
|
169
|
-
const module = appModules[i];
|
|
170
|
-
const name = module.name;
|
|
171
|
-
if (!seen[name]) {
|
|
172
|
-
modules[count++] = module;
|
|
173
|
-
seen[name] = true;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
modules.length = count;
|
|
177
|
-
return modules;
|
|
178
|
-
}
|
|
179
83
|
}
|
|
84
|
+
_defineProperty(PipelineFactory, "defaultProps", {
|
|
85
|
+
...RenderPipeline.defaultProps,
|
|
86
|
+
vs: undefined,
|
|
87
|
+
fs: undefined
|
|
88
|
+
});
|
|
180
89
|
//# sourceMappingURL=pipeline-factory.js.map
|
|
@@ -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/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\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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zBoE,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":["RenderPipeline","PipelineFactory","getDefaultPipelineFactory","device","_lumaData","defaultPipelineFactory","constructor","_defineProperty","createRenderPipeline","options","props","defaultProps","hash","_hashRenderPipeline","_pipelineCache","pipeline","vs","createShader","stage","source","fs","_useCounts","release","destroy","_createRenderPipeline","Error","vsHash","_getHash","fsHash","parameterHash","JSON","stringify","parameters","bufferLayoutHash","bufferLayout","varyingHash","concat","topology","key","_hashes","undefined","_hashCounter"],"sources":["../../src/lib/pipeline-factory.ts"],"sourcesContent":["import type {RenderPipelineProps} from '@luma.gl/core';\nimport {Device, RenderPipeline} from '@luma.gl/core';\n\n/** Todo - should be same as RenderPipelineProps */\nexport type PipelineFactoryProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Only accepts string shaders\n vs: string;\n fs: string;\n};\n\n/** \n * Efficiently creates / caches pipelines\n */\nexport class PipelineFactory {\n static defaultProps: Required<PipelineFactoryProps> = {\n ...RenderPipeline.defaultProps,\n vs: undefined!,\n fs: undefined!\n }\n\n readonly device: Device;\n\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n device._lumaData.defaultPipelineFactory = device._lumaData.defaultPipelineFactory || new PipelineFactory(device);\n return device._lumaData.defaultPipelineFactory as PipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n createRenderPipeline(options: PipelineFactoryProps): RenderPipeline {\n const props: Required<PipelineFactoryProps> = {...PipelineFactory.defaultProps, ...options};\n\n const hash = this._hashRenderPipeline({...props});\n\n if (!this._pipelineCache[hash]) {\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._pipelineCache[hash];\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._useCounts[hash];\n }\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: PipelineFactoryProps): RenderPipeline {\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: props.vs}),\n fs: props.fs ? this.device.createShader({stage: 'fragment', source: props.fs}) : null,\n });\n\n return pipeline;\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: PipelineFactoryProps): string {\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n // TODO - Can json.stringify() generate different strings for equivalent objects if order of params is different?\n // create a deepHash() to deduplicate?\n\n // hash parameters\n const parameterHash = this._getHash(JSON.stringify(props.parameters));\n\n // hash buffer layouts\n const bufferLayoutHash = this._getHash(JSON.stringify(props.bufferLayout));\n\n // WebGL specific\n // const {varyings = [], bufferMode = {}} = props;\n // const varyingHashes = varyings.map((v) => this._getHash(v));\n const varyingHash = '-'; // `${varyingHashes.join('/')}B${bufferMode}`\n\n return `${vsHash}/${fsHash}V${varyingHash}T${props.topology}P${parameterHash}BL${bufferLayoutHash}}`;\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\n"],"mappings":";AACA,SAAgBA,cAAc,QAAO,eAAe;AAYpD,OAAO,MAAMC,eAAe,CAAC;E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AACU,EAAE,CAAC,GAAG,CAAC;IAMrD,MAAMS,aAAa,GAAG,IAAI,CAACF,QAAQ,CAACG,IAAI,CAACC,SAAS,CAACrB,KAAK,CAACsB,UAAU,CAAC,CAAC;IAGrE,MAAMC,gBAAgB,GAAG,IAAI,CAACN,QAAQ,CAACG,IAAI,CAACC,SAAS,CAACrB,KAAK,CAACwB,YAAY,CAAC,CAAC;IAK1E,MAAMC,WAAW,GAAG,GAAG;IAEvB,UAAAC,MAAA,CAAUV,MAAM,OAAAU,MAAA,CAAIR,MAAM,OAAAQ,MAAA,CAAID,WAAW,OAAAC,MAAA,CAAI1B,KAAK,CAAC2B,QAAQ,OAAAD,MAAA,CAAIP,aAAa,QAAAO,MAAA,CAAKH,gBAAgB;EACnG;EAEAN,QAAQA,CAACW,GAAW,EAAU;IAC5B,IAAI,IAAI,CAACC,OAAO,CAACD,GAAG,CAAC,KAAKE,SAAS,EAAE;MACnC,IAAI,CAACD,OAAO,CAACD,GAAG,CAAC,GAAG,IAAI,CAACG,YAAY,EAAE;IACzC;IACA,OAAO,IAAI,CAACF,OAAO,CAACD,GAAG,CAAC;EAC1B;AACF;AAAC/B,eAAA,CAnGYN,eAAe,kBAC4B;EACpD,GAAGD,cAAc,CAACW,YAAY;EAC9BK,EAAE,EAAEwB,SAAU;EACdpB,EAAE,EAAEoB;AACN,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Device } from '@luma.gl/core';
|
|
2
|
+
import type { ShaderModule, HookFunction } from '@luma.gl/shadertools';
|
|
3
|
+
import { ShaderAssembler } from '@luma.gl/shadertools';
|
|
4
|
+
export type ModelShaderProps = {
|
|
5
|
+
vs?: {
|
|
6
|
+
glsl?: string;
|
|
7
|
+
wgsl?: string;
|
|
8
|
+
} | string | null;
|
|
9
|
+
fs?: {
|
|
10
|
+
glsl?: string;
|
|
11
|
+
wgsl?: string;
|
|
12
|
+
} | string | null;
|
|
13
|
+
/** shadertool shader modules (added to shader code) */
|
|
14
|
+
modules?: ShaderModule[];
|
|
15
|
+
/** Shadertool module defines (configures shader code)*/
|
|
16
|
+
defines?: Record<string, string | number | boolean>;
|
|
17
|
+
inject?: Record<string, string>;
|
|
18
|
+
hooks?: Record<string, HookFunction>;
|
|
19
|
+
transpileToGLSL100?: boolean;
|
|
20
|
+
shaderAssembler: ShaderAssembler;
|
|
21
|
+
};
|
|
22
|
+
type GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;
|
|
23
|
+
/**
|
|
24
|
+
* TODO - should this functionality move into shadertools / assembleShaders ?
|
|
25
|
+
* @param device
|
|
26
|
+
* @param props
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildShaders(device: Device, props: ModelShaderProps): {
|
|
30
|
+
vs: string;
|
|
31
|
+
fs: string | undefined;
|
|
32
|
+
getUniforms: GetUniformsFunc;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=model-shaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-shaders.d.ts","sourceRoot":"","sources":["../../src/model/model-shaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAE7B,EAAE,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACpD,EAAE,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACpD,uDAAuD;IACvD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAEF,KAAK,eAAe,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,gBAAgB,GACtB;IACD,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,WAAW,EAAE,eAAe,CAAA;CAC7B,CAmBA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function buildShaders(device, props) {
|
|
2
|
+
if (!props.vs) {
|
|
3
|
+
throw new Error('no vertex shader');
|
|
4
|
+
}
|
|
5
|
+
const vs = getShaderSource(device, props.vs);
|
|
6
|
+
let fs;
|
|
7
|
+
if (props.fs) {
|
|
8
|
+
fs = getShaderSource(device, props.fs);
|
|
9
|
+
}
|
|
10
|
+
const platformInfo = {
|
|
11
|
+
type: device.info.type,
|
|
12
|
+
gpu: device.info.gpu,
|
|
13
|
+
features: device.features
|
|
14
|
+
};
|
|
15
|
+
return props.shaderAssembler.assembleShaders(platformInfo, {
|
|
16
|
+
...props,
|
|
17
|
+
fs,
|
|
18
|
+
vs
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function getShaderSource(device, shader) {
|
|
22
|
+
if (typeof shader === 'string') {
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
25
|
+
switch (device.info.type) {
|
|
26
|
+
case 'webgpu':
|
|
27
|
+
if (shader !== null && shader !== void 0 && shader.wgsl) {
|
|
28
|
+
return shader.wgsl;
|
|
29
|
+
}
|
|
30
|
+
throw new Error('WebGPU does not support GLSL shaders');
|
|
31
|
+
default:
|
|
32
|
+
if (shader !== null && shader !== void 0 && shader.glsl) {
|
|
33
|
+
return shader.glsl;
|
|
34
|
+
}
|
|
35
|
+
throw new Error('WebGL does not support WGSL shaders');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=model-shaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-shaders.js","names":["buildShaders","device","props","vs","Error","getShaderSource","fs","platformInfo","type","info","gpu","features","shaderAssembler","assembleShaders","shader","wgsl","glsl"],"sources":["../../src/model/model-shaders.ts"],"sourcesContent":["import type {Device} from '@luma.gl/core';\nimport type {ShaderModule, HookFunction} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\n\nexport type ModelShaderProps = {\n // Model also accepts a string shaders\n vs?: {glsl?: string; wgsl?: string} | string | null;\n fs?: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n hooks?: Record<string, HookFunction>;\n transpileToGLSL100?: boolean;\n\n shaderAssembler: ShaderAssembler;\n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/**\n * TODO - should this functionality move into shadertools / assembleShaders ?\n * @param device\n * @param props\n * @returns\n */\nexport function buildShaders(\n device: Device,\n props: ModelShaderProps\n): {\n vs: string; \n fs: string | undefined; \n getUniforms: GetUniformsFunc\n} {\n if (!props.vs) {\n throw new Error('no vertex shader');\n }\n\n // Resolve WGSL vs GLSL\n const vs = getShaderSource(device, props.vs);\n let fs;\n if (props.fs) {\n fs = getShaderSource(device, props.fs);\n }\n\n const platformInfo = {\n type: device.info.type,\n gpu: device.info.gpu,\n features: device.features\n };\n\n return props.shaderAssembler.assembleShaders(platformInfo, {...props, fs, vs});\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":"AA2BA,OAAO,SAASA,YAAYA,CAC1BC,MAAc,EACdC,KAAuB,EAKvB;EACA,IAAI,CAACA,KAAK,CAACC,EAAE,EAAE;IACb,MAAM,IAAIC,KAAK,CAAC,kBAAkB,CAAC;EACrC;EAGA,MAAMD,EAAE,GAAGE,eAAe,CAACJ,MAAM,EAAEC,KAAK,CAACC,EAAE,CAAC;EAC5C,IAAIG,EAAE;EACN,IAAIJ,KAAK,CAACI,EAAE,EAAE;IACZA,EAAE,GAAGD,eAAe,CAACJ,MAAM,EAAEC,KAAK,CAACI,EAAE,CAAC;EACxC;EAEA,MAAMC,YAAY,GAAG;IACnBC,IAAI,EAAEP,MAAM,CAACQ,IAAI,CAACD,IAAI;IACtBE,GAAG,EAAET,MAAM,CAACQ,IAAI,CAACC,GAAG;IACpBC,QAAQ,EAAEV,MAAM,CAACU;EACnB,CAAC;EAED,OAAOT,KAAK,CAACU,eAAe,CAACC,eAAe,CAACN,YAAY,EAAE;IAAC,GAAGL,KAAK;IAAEI,EAAE;IAAEH;EAAE,CAAC,CAAC;AAChF;AAGA,SAASE,eAAeA,CAACJ,MAAc,EAAEa,MAA+C,EAAU;EAEhG,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOA,MAAM;EACf;EAEA,QAAQb,MAAM,CAACQ,IAAI,CAACD,IAAI;IACtB,KAAK,QAAQ;MACX,IAAIM,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,IAAI,EAAE;QAChB,OAAOD,MAAM,CAACC,IAAI;MACpB;MACA,MAAM,IAAIX,KAAK,CAAC,sCAAsC,CAAC;IAEzD;MACE,IAAIU,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEE,IAAI,EAAE;QAChB,OAAOF,MAAM,CAACE,IAAI;MACpB;MACA,MAAM,IAAIZ,KAAK,CAAC,qCAAqC,CAAC;EAC1D;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Device, Buffer } from '@luma.gl/core';
|
|
2
2
|
import type { Geometry } from '../geometry/geometry';
|
|
3
|
-
export declare function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer |
|
|
3
|
+
export declare function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | null;
|
|
4
4
|
export declare function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): Record<string, Buffer>;
|
|
5
5
|
//# sourceMappingURL=model-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../src/model/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAS,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAsDnD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../src/model/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAS,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAsDnD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAY5F;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAc1G"}
|
|
@@ -9,7 +9,7 @@ const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
|
|
|
9
9
|
};
|
|
10
10
|
export function getIndexBufferFromGeometry(device, geometry) {
|
|
11
11
|
if (!geometry.indices) {
|
|
12
|
-
return
|
|
12
|
+
return null;
|
|
13
13
|
}
|
|
14
14
|
const data = geometry.indices.value || geometry.indices;
|
|
15
15
|
assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
|
|
@@ -1 +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","
|
|
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","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/core';\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 | null {\n if (!geometry.indices) {\n return null;\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,eAAe;AAIpD,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,EAAiB;EAC5F,IAAI,CAACA,QAAQ,CAACC,OAAO,EAAE;IACrB,OAAO,IAAI;EACb;EAGA,MAAMC,IAAI,GAAGF,QAAQ,CAACC,OAAO,CAACE,KAAK,IAAIH,QAAQ,CAACC,OAAO;EACvDX,MAAM,CACJY,IAAI,YAAYE,WAAW,IAAIF,IAAI,YAAYG,WAAW,EAC1D,uDACF,CAAC;EACD,OAAON,MAAM,CAACO,YAAY,CAAC;IAACC,KAAK,EAAElB,MAAM,CAACmB,KAAK;IAAEN;EAAI,CAAC,CAAC;AACzD;AAEA,OAAO,SAASO,+BAA+BA,CAACV,MAAc,EAAEC,QAAkB,EAA0B;EAC1G,MAAMU,OAA+B,GAAG,CAAC,CAAC;EAE1C,KAAK,MAAM,CAACC,IAAI,EAAEC,SAAS,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACd,QAAQ,CAACe,UAAU,CAAC,EAAE;IACnE,MAAMC,YAAY,GAAGC,gBAAgB,CAACN,IAAI,CAAC;IAC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