zincjs 2.4.1-beta.6 → 2.4.1-beta.7
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/build/zinc.js +3 -3
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/glyphset.js +14 -2
- package/src/renderer.js +4 -0
- package/src/tsl/glyphTransform.js +22 -1
package/package.json
CHANGED
|
@@ -3,7 +3,8 @@ import { Glyph } from './glyph';
|
|
|
3
3
|
import { ZincObject } from './zincObject';
|
|
4
4
|
import { updateWorldMatrixFromAncestors } from '../utilities';
|
|
5
5
|
import { JSONLoader } from '../loaders/JSONLoader';
|
|
6
|
-
import { createGlyphTransformCompute, dispatchAndReadbackGlyphTransform,
|
|
6
|
+
import { createGlyphTransformCompute, dispatchAndReadbackGlyphTransform, isGlyphComputeSupported,
|
|
7
|
+
readbackGlyphTransform } from '../tsl/glyphTransform';
|
|
7
8
|
import { createGlyphInstancedMaterial } from '../tsl/glyphRenderMaterial';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -176,7 +177,9 @@ const Glyphset = function () {
|
|
|
176
177
|
offset = glyphsetData.metadata.offset;
|
|
177
178
|
scaleFactors = glyphsetData.metadata.scale_factors;
|
|
178
179
|
glyphCompute = undefined;
|
|
179
|
-
|
|
180
|
+
//The CPU path is used when the backend does not support GPU compute
|
|
181
|
+
if (morphVertices && numberOfTimeSteps > 1 && positions && positions["0"] &&
|
|
182
|
+
isGlyphComputeSupported()) {
|
|
180
183
|
const baseCount = positions["0"].length / 3;
|
|
181
184
|
try {
|
|
182
185
|
glyphCompute = createGlyphTransformCompute({
|
|
@@ -699,6 +702,15 @@ const Glyphset = function () {
|
|
|
699
702
|
}
|
|
700
703
|
};
|
|
701
704
|
|
|
705
|
+
/**
|
|
706
|
+
* Check if the glyph transforms are animated on the GPU.
|
|
707
|
+
*
|
|
708
|
+
* @return {Boolean}
|
|
709
|
+
*/
|
|
710
|
+
this.isUsingGPUCompute = () => {
|
|
711
|
+
return glyphCompute !== undefined;
|
|
712
|
+
}
|
|
713
|
+
|
|
702
714
|
/**
|
|
703
715
|
* Get the assigned label for instance at index
|
|
704
716
|
*/
|
package/src/renderer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ResizeSensor } from 'css-element-queries';
|
|
|
3
3
|
import { Scene } from './scene';
|
|
4
4
|
import { onRenderRequest, offRenderRequest } from './renderRequests';
|
|
5
5
|
import { setTextPixelsPerUnit } from './textSprite';
|
|
6
|
+
import { setGlyphComputeSupported } from './tsl/glyphTransform';
|
|
6
7
|
/**
|
|
7
8
|
* Create a Zinc 3D renderer in the container provided.
|
|
8
9
|
* The primary function of a Zinc 3D renderer is to display the current
|
|
@@ -173,6 +174,9 @@ const Renderer = function (containerIn) {
|
|
|
173
174
|
}
|
|
174
175
|
renderer = new THREE.WebGPURenderer(parameters);
|
|
175
176
|
await renderer.init();
|
|
177
|
+
//GPU glyph animation requires the WebGPU backend, the WebGL fallback
|
|
178
|
+
//cannot index storage buffers freely.
|
|
179
|
+
setGlyphComputeSupported(renderer.backend?.isWebGPUBackend === true);
|
|
176
180
|
|
|
177
181
|
//renderer = new THREE.WebGLRenderer(parameters);
|
|
178
182
|
if (container !== undefined) {
|
|
@@ -334,4 +334,25 @@ async function dispatchAndReadbackGlyphTransform(renderer, glyphCompute) {
|
|
|
334
334
|
return readbackGlyphTransform(renderer, glyphCompute);
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
|
|
337
|
+
/*
|
|
338
|
+
* The GPU glyph transforms read storage buffers at arbitrary indices, which
|
|
339
|
+
* the WebGL fallback backend of WebGPURenderer does not support (it turns
|
|
340
|
+
* them into plain vertex attributes). The renderer sets this when it is
|
|
341
|
+
* initialised, glyphsets use the CPU animation path when it is false.
|
|
342
|
+
*/
|
|
343
|
+
let glyphComputeSupported = true;
|
|
344
|
+
|
|
345
|
+
const setGlyphComputeSupported = (flag) => {
|
|
346
|
+
glyphComputeSupported = flag ? true : false;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const isGlyphComputeSupported = () => glyphComputeSupported;
|
|
350
|
+
|
|
351
|
+
export {
|
|
352
|
+
createGlyphTransformCompute,
|
|
353
|
+
dispatchAndReadbackGlyphTransform,
|
|
354
|
+
isGlyphComputeSupported,
|
|
355
|
+
readbackGlyphTransform,
|
|
356
|
+
setGlyphComputeSupported,
|
|
357
|
+
REPEAT_MODE,
|
|
358
|
+
};
|