soonspacejs 2.7.3 → 2.8.0
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/generateBVH.worker.js +57 -1
- package/dist/generateBVH.worker.js.map +1 -0
- package/dist/index.esm.js +34809 -2
- package/dist/index.esm.js.map +1 -0
- package/package.json +2 -2
- package/types/Animation/createPathAnimation.d.ts +12 -12
- package/types/Library/Model.d.ts +1 -1
- package/types/index.d.ts +5 -4
|
@@ -1 +1,57 @@
|
|
|
1
|
-
import{BufferGeometry
|
|
1
|
+
import { BufferGeometry, BufferAttribute } from 'three';
|
|
2
|
+
import { MeshBVH } from 'three-mesh-bvh';
|
|
3
|
+
|
|
4
|
+
onmessage = function ({ data, }) {
|
|
5
|
+
let prevTime = performance.now();
|
|
6
|
+
function onProgressCallback(progress) {
|
|
7
|
+
const currTime = performance.now();
|
|
8
|
+
if (currTime - prevTime >= 10 || progress === 1.0) {
|
|
9
|
+
postMessage({
|
|
10
|
+
error: null,
|
|
11
|
+
serialized: null,
|
|
12
|
+
position: null,
|
|
13
|
+
progress,
|
|
14
|
+
});
|
|
15
|
+
prevTime = currTime;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
if (!data) {
|
|
20
|
+
postMessage(data);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { index, position, options, } = data;
|
|
24
|
+
const geometry = new BufferGeometry();
|
|
25
|
+
geometry.setAttribute('position', new BufferAttribute(position, 3, false));
|
|
26
|
+
if (index) {
|
|
27
|
+
geometry.setIndex(new BufferAttribute(index, 1, false));
|
|
28
|
+
}
|
|
29
|
+
if (options.includedProgressCallback) {
|
|
30
|
+
options.onProgress = onProgressCallback;
|
|
31
|
+
}
|
|
32
|
+
if (options.groups) {
|
|
33
|
+
const groups = options.groups;
|
|
34
|
+
for (const i in groups) {
|
|
35
|
+
const group = groups[i];
|
|
36
|
+
geometry.addGroup(group.start, group.count, group.materialIndex);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const bvh = new MeshBVH(geometry, options);
|
|
40
|
+
const serialized = MeshBVH.serialize(bvh, { cloneBuffers: false, });
|
|
41
|
+
postMessage({
|
|
42
|
+
error: null,
|
|
43
|
+
serialized,
|
|
44
|
+
position,
|
|
45
|
+
progress: 1,
|
|
46
|
+
}, [position.buffer, ...serialized.roots]);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
postMessage({
|
|
50
|
+
error,
|
|
51
|
+
serialized: null,
|
|
52
|
+
position: null,
|
|
53
|
+
progress: 1,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=generateBVH.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateBVH.worker.js","sources":["../src/Viewport/Bvh/generateBVH.worker.ts"],"sourcesContent":["import {\n BufferGeometry,\n BufferAttribute,\n} from 'three'\nimport { MeshBVH, } from 'three-mesh-bvh'\n\nonmessage = function ( { data, } ) {\n\n let prevTime = performance.now()\n\n function onProgressCallback ( progress: any ) {\n\n const currTime = performance.now()\n\n if ( currTime - prevTime >= 10 || progress === 1.0 ) {\n\n postMessage( {\n\n error: null,\n serialized: null,\n position: null,\n progress,\n\n } )\n prevTime = currTime\n\n }\n\n }\n\n try {\n\n if ( !data ) {\n\n postMessage( data )\n\n return \n \n }\n\n const { index, position, options, } = data\n\n const geometry = new BufferGeometry()\n\n geometry.setAttribute( 'position', new BufferAttribute( position, 3, false ) )\n\n if ( index ) {\n\n geometry.setIndex( new BufferAttribute( index, 1, false ) )\n\n }\n\n if ( options.includedProgressCallback ) {\n\n options.onProgress = onProgressCallback\n\n }\n\n if ( options.groups ) {\n\n const groups = options.groups\n\n for ( const i in groups ) {\n\n const group = groups[ i ]\n\n geometry.addGroup( group.start, group.count, group.materialIndex )\n\n }\n\n }\n\n const bvh = new MeshBVH( geometry, options )\n const serialized = MeshBVH.serialize( bvh, { cloneBuffers: false, } )\n\n postMessage( {\n\n error: null,\n serialized,\n position,\n progress: 1,\n\n }, [ position.buffer, ...serialized.roots ] )\n\n } catch ( error ) {\n\n postMessage( {\n\n error,\n serialized: null,\n position: null,\n progress: 1,\n\n } )\n\n }\n\n}\n"],"names":[],"mappings":";;;AAMA,SAAS,GAAG,UAAW,EAAE,IAAI,GAAG,EAAA;AAE9B,IAAA,IAAI,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAEhC,SAAS,kBAAkB,CAAG,QAAa,EAAA;AAEzC,QAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAElC,IAAK,QAAQ,GAAG,QAAQ,IAAI,EAAE,IAAI,QAAQ,KAAK,GAAG,EAAG;AAEnD,YAAA,WAAW,CAAE;AAEX,gBAAA,KAAK,EAAE,IAAI;AACX,gBAAA,UAAU,EAAE,IAAI;AAChB,gBAAA,QAAQ,EAAE,IAAI;gBACd,QAAQ;AAET,aAAA,CAAE,CAAA;YACH,QAAQ,GAAG,QAAQ,CAAA;AAEpB,SAAA;KAEF;IAED,IAAI;QAEF,IAAK,CAAC,IAAI,EAAG;YAEX,WAAW,CAAE,IAAI,CAAE,CAAA;YAEnB,OAAM;AAEP,SAAA;QAED,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,GAAG,GAAG,IAAI,CAAA;AAE1C,QAAA,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAA;AAErC,QAAA,QAAQ,CAAC,YAAY,CAAE,UAAU,EAAE,IAAI,eAAe,CAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAE,CAAE,CAAA;AAE9E,QAAA,IAAK,KAAK,EAAG;AAEX,YAAA,QAAQ,CAAC,QAAQ,CAAE,IAAI,eAAe,CAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAE,CAAE,CAAA;AAE5D,SAAA;QAED,IAAK,OAAO,CAAC,wBAAwB,EAAG;AAE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