@gnsx/three 0.185.14 → 0.185.15
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/three.cjs +682 -0
- package/build/three.core.js +669 -1
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +1 -1
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +1 -1
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +1 -1
- package/build/three.webgpu.nodes.min.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +17 -0
- package/src/core/NodePath.js +208 -0
- package/src/core/Object3D.js +191 -0
- package/src/core/nodeId.js +168 -0
- package/src/loaders/ObjectLoader.js +4 -0
- package/src/math/XorShift32.js +119 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// WITH_GENESYS
|
|
2
|
+
/**
|
|
3
|
+
* Shared deterministic PRNG helpers (FNV-1a seed hash + xorshift32).
|
|
4
|
+
* Used by sibling-local nodeId allocation and other deterministic streams.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight FNV-1a hash for converting strings into a deterministic 32-bit seed.
|
|
9
|
+
* @param {string} input
|
|
10
|
+
* @return {number}
|
|
11
|
+
*/
|
|
12
|
+
function hashStringToUint32( input ) {
|
|
13
|
+
|
|
14
|
+
let hash = 0x811c9dc5;
|
|
15
|
+
|
|
16
|
+
for ( let i = 0; i < input.length; i ++ ) {
|
|
17
|
+
|
|
18
|
+
hash ^= input.charCodeAt( i );
|
|
19
|
+
hash = Math.imul( hash, 0x01000193 );
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return ( hash >>> 0 ) || 0x9e3779b9;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Xorshift32 step; deterministic and fast for ID generation. Never returns 0.
|
|
29
|
+
* @param {number} state
|
|
30
|
+
* @return {number}
|
|
31
|
+
*/
|
|
32
|
+
function xorshift32( state ) {
|
|
33
|
+
|
|
34
|
+
let next = state | 0;
|
|
35
|
+
next ^= next << 13;
|
|
36
|
+
next ^= next >>> 17;
|
|
37
|
+
next ^= next << 5;
|
|
38
|
+
return ( next >>> 0 ) || 0x9e3779b9;
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Random non-zero uint32 seed for non-deterministic streams.
|
|
44
|
+
* @return {number}
|
|
45
|
+
*/
|
|
46
|
+
function randomSeedUint32() {
|
|
47
|
+
|
|
48
|
+
return ( ( Math.random() * 0x100000000 ) >>> 0 ) || 0x9e3779b9;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Deterministic xorshift32 stream. Internal state is never 0.
|
|
54
|
+
*/
|
|
55
|
+
class XorShift32 {
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {number|string} [seed]
|
|
59
|
+
*/
|
|
60
|
+
constructor( seed = randomSeedUint32() ) {
|
|
61
|
+
|
|
62
|
+
this._state = typeof seed === 'string'
|
|
63
|
+
? hashStringToUint32( seed )
|
|
64
|
+
: ( ( seed >>> 0 ) || 0x9e3779b9 );
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Advance and return the next non-zero uint32.
|
|
70
|
+
* @return {number}
|
|
71
|
+
*/
|
|
72
|
+
nextUint32() {
|
|
73
|
+
|
|
74
|
+
this._state = xorshift32( this._state );
|
|
75
|
+
return this._state;
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Advance and return the low 16 bits (0 is allowed).
|
|
81
|
+
* @return {number}
|
|
82
|
+
*/
|
|
83
|
+
nextUint16() {
|
|
84
|
+
|
|
85
|
+
return this.nextUint32() & 0xffff;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @return {number}
|
|
91
|
+
*/
|
|
92
|
+
getState() {
|
|
93
|
+
|
|
94
|
+
return this._state >>> 0;
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {number} state
|
|
100
|
+
*/
|
|
101
|
+
setState( state ) {
|
|
102
|
+
|
|
103
|
+
this._state = ( state >>> 0 ) || 0x9e3779b9;
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @return {XorShift32}
|
|
109
|
+
*/
|
|
110
|
+
clone() {
|
|
111
|
+
|
|
112
|
+
return new XorShift32( this._state );
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { hashStringToUint32, xorshift32, randomSeedUint32, XorShift32 };
|
|
119
|
+
// !WITH_GENESYS
|