@babylonjs-toolkit/next 9.0.1

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.
Files changed (131) hide show
  1. package/README.md +319 -0
  2. package/lib/blendtreeposition.d.ts +5 -0
  3. package/lib/blendtreeposition.d.ts.map +1 -0
  4. package/lib/blendtreeposition.js +5 -0
  5. package/lib/channelmixerplugin.d.ts +11 -0
  6. package/lib/channelmixerplugin.d.ts.map +1 -0
  7. package/lib/channelmixerplugin.js +34 -0
  8. package/lib/collisioncontact.d.ts +7 -0
  9. package/lib/collisioncontact.d.ts.map +1 -0
  10. package/lib/collisioncontact.js +7 -0
  11. package/lib/collisionfilters.d.ts +10 -0
  12. package/lib/collisionfilters.d.ts.map +1 -0
  13. package/lib/collisionfilters.js +10 -0
  14. package/lib/collisionflags.d.ts +14 -0
  15. package/lib/collisionflags.d.ts.map +1 -0
  16. package/lib/collisionflags.js +14 -0
  17. package/lib/collisionstate.d.ts +8 -0
  18. package/lib/collisionstate.d.ts.map +1 -0
  19. package/lib/collisionstate.js +8 -0
  20. package/lib/customloadingscreen.d.ts +16 -0
  21. package/lib/customloadingscreen.d.ts.map +1 -0
  22. package/lib/customloadingscreen.js +48 -0
  23. package/lib/entitycontroller.d.ts +11 -0
  24. package/lib/entitycontroller.d.ts.map +1 -0
  25. package/lib/entitycontroller.js +41 -0
  26. package/lib/fontmanifestentry.d.ts +8 -0
  27. package/lib/fontmanifestentry.d.ts.map +1 -0
  28. package/lib/fontmanifestentry.js +1 -0
  29. package/lib/handedness.d.ts +6 -0
  30. package/lib/handedness.d.ts.map +1 -0
  31. package/lib/handedness.js +6 -0
  32. package/lib/ianimationcurve.d.ts +14 -0
  33. package/lib/ianimationcurve.d.ts.map +1 -0
  34. package/lib/ianimationcurve.js +1 -0
  35. package/lib/index.d.ts +43 -0
  36. package/lib/index.d.ts.map +1 -0
  37. package/lib/index.js +42 -0
  38. package/lib/intersectionprecision.d.ts +5 -0
  39. package/lib/intersectionprecision.d.ts.map +1 -0
  40. package/lib/intersectionprecision.js +5 -0
  41. package/lib/iparticlesystemtransform.d.ts +9 -0
  42. package/lib/iparticlesystemtransform.d.ts.map +1 -0
  43. package/lib/iparticlesystemtransform.js +1 -0
  44. package/lib/irecastnavigationplugin.d.ts +92 -0
  45. package/lib/irecastnavigationplugin.d.ts.map +1 -0
  46. package/lib/irecastnavigationplugin.js +1 -0
  47. package/lib/linesmeshrenderer.d.ts +22 -0
  48. package/lib/linesmeshrenderer.d.ts.map +1 -0
  49. package/lib/linesmeshrenderer.js +79 -0
  50. package/lib/localmessagebus.d.ts +9 -0
  51. package/lib/localmessagebus.d.ts.map +1 -0
  52. package/lib/localmessagebus.js +44 -0
  53. package/lib/lutblendplugin.d.ts +13 -0
  54. package/lib/lutblendplugin.d.ts.map +1 -0
  55. package/lib/lutblendplugin.js +153 -0
  56. package/lib/mousebuttonmode.d.ts +6 -0
  57. package/lib/mousebuttonmode.d.ts.map +1 -0
  58. package/lib/mousebuttonmode.js +6 -0
  59. package/lib/movementtype.d.ts +5 -0
  60. package/lib/movementtype.d.ts.map +1 -0
  61. package/lib/movementtype.js +5 -0
  62. package/lib/noisefunction2d.d.ts +2 -0
  63. package/lib/noisefunction2d.d.ts.map +1 -0
  64. package/lib/noisefunction2d.js +1 -0
  65. package/lib/noisefunction3d.d.ts +2 -0
  66. package/lib/noisefunction3d.d.ts.map +1 -0
  67. package/lib/noisefunction3d.js +1 -0
  68. package/lib/noisefunction4d.d.ts +2 -0
  69. package/lib/noisefunction4d.d.ts.map +1 -0
  70. package/lib/noisefunction4d.js +1 -0
  71. package/lib/perlin2d.d.ts +9 -0
  72. package/lib/perlin2d.d.ts.map +1 -0
  73. package/lib/perlin2d.js +45 -0
  74. package/lib/playercontrol.d.ts +5 -0
  75. package/lib/playercontrol.d.ts.map +1 -0
  76. package/lib/playercontrol.js +5 -0
  77. package/lib/prefabobjectpool.d.ts +20 -0
  78. package/lib/prefabobjectpool.d.ts.map +1 -0
  79. package/lib/prefabobjectpool.js +96 -0
  80. package/lib/randomfn.d.ts +2 -0
  81. package/lib/randomfn.d.ts.map +1 -0
  82. package/lib/randomfn.js +1 -0
  83. package/lib/raycasthitresult.d.ts +21 -0
  84. package/lib/raycasthitresult.d.ts.map +1 -0
  85. package/lib/raycasthitresult.js +36 -0
  86. package/lib/recastclassctor.d.ts +2 -0
  87. package/lib/recastclassctor.d.ts.map +1 -0
  88. package/lib/recastclassctor.js +1 -0
  89. package/lib/roomerrormessage.d.ts +5 -0
  90. package/lib/roomerrormessage.d.ts.map +1 -0
  91. package/lib/roomerrormessage.js +2 -0
  92. package/lib/scenemanager.d.ts +4141 -0
  93. package/lib/scenemanager.d.ts.map +1 -0
  94. package/lib/scenemanager.js +29628 -0
  95. package/lib/simplexnoise.d.ts +21 -0
  96. package/lib/simplexnoise.d.ts.map +1 -0
  97. package/lib/simplexnoise.js +362 -0
  98. package/lib/touchjoystickhandler.d.ts +39 -0
  99. package/lib/touchjoystickhandler.d.ts.map +1 -0
  100. package/lib/touchjoystickhandler.js +175 -0
  101. package/lib/touchmousebutton.d.ts +6 -0
  102. package/lib/touchmousebutton.d.ts.map +1 -0
  103. package/lib/touchmousebutton.js +6 -0
  104. package/lib/treebranchmaterial.d.ts +31 -0
  105. package/lib/treebranchmaterial.d.ts.map +1 -0
  106. package/lib/treebranchmaterial.js +369 -0
  107. package/lib/triggervolume.d.ts +6 -0
  108. package/lib/triggervolume.d.ts.map +1 -0
  109. package/lib/triggervolume.js +6 -0
  110. package/lib/unitydropdownmenu.d.ts +20 -0
  111. package/lib/unitydropdownmenu.d.ts.map +1 -0
  112. package/lib/unitydropdownmenu.js +144 -0
  113. package/lib/unityscrollbar.d.ts +11 -0
  114. package/lib/unityscrollbar.d.ts.map +1 -0
  115. package/lib/unityscrollbar.js +38 -0
  116. package/lib/unityslider.d.ts +4 -0
  117. package/lib/unityslider.d.ts.map +1 -0
  118. package/lib/unityslider.js +3 -0
  119. package/lib/universalcharactercontroller.d.ts +3 -0
  120. package/lib/universalcharactercontroller.d.ts.map +1 -0
  121. package/lib/universalcharactercontroller.js +1 -0
  122. package/lib/universalterrainmaterial.d.ts +48 -0
  123. package/lib/universalterrainmaterial.d.ts.map +1 -0
  124. package/lib/universalterrainmaterial.js +639 -0
  125. package/lib/userinputpointer.d.ts +6 -0
  126. package/lib/userinputpointer.d.ts.map +1 -0
  127. package/lib/userinputpointer.js +6 -0
  128. package/lib/xbox360trigger.d.ts +5 -0
  129. package/lib/xbox360trigger.d.ts.map +1 -0
  130. package/lib/xbox360trigger.js +5 -0
  131. package/package.json +211 -0
@@ -0,0 +1,369 @@
1
+ import { Vector4, Vector3 } from '@babylonjs/core/Maths/math.vector';
2
+ import { CustomShaderMaterial, SceneManager, CustomShaderMaterialPlugin } from './scenemanager';
3
+ import { ShaderLanguage } from '@babylonjs/core/Materials';
4
+ export class TreeBranchMaterial extends CustomShaderMaterial {
5
+ constructor(name, scene) {
6
+ super(name, scene);
7
+ this._windTimeAccum = 0.0;
8
+ this.shader = this.getShaderName();
9
+ this.plugin = new TreeBranchMaterialPlugin(this, this.shader);
10
+ this.addFloatUniform("g_windTime", 0.0);
11
+ this.addFloatUniform("g_windAmount", 0.5);
12
+ this.addFloatUniform("g_windSpeed", 1.0);
13
+ this.addFloatUniform("g_windStrength", 0.5);
14
+ this.addVector4Uniform("g_windDirection", new Vector4(1.0, 0.0, 0.0, 0.0));
15
+ this.addFloatUniform("g_branchRootY", 0.0);
16
+ this.addFloatUniform("g_branchMaxAngle", 0.35);
17
+ this.addFloatUniform("g_branchMaxHeight", 2.0);
18
+ this.addFloatUniform("g_useVertexColorMask", 1.0);
19
+ this.addFloatUniform("g_spatialFrequency", 0.15);
20
+ this._windTimeAccum = 0.0;
21
+ }
22
+ awake() {
23
+ }
24
+ update() {
25
+ try {
26
+ const rawDt = SceneManager.GetDeltaSeconds(this.getScene());
27
+ const dt = Math.min(rawDt, 1 / 30);
28
+ const speed = this.getFloatValue("g_windSpeed") ?? 0;
29
+ if (speed > 0) {
30
+ this._windTimeAccum += dt;
31
+ this.setFloatValue("g_windTime", this._windTimeAccum);
32
+ }
33
+ }
34
+ catch (e) {
35
+ }
36
+ }
37
+ getShaderName() {
38
+ return "TreeBranchMaterial";
39
+ }
40
+ setWindDirection(x, y, z) {
41
+ const v = new Vector3(x, y, z);
42
+ if (v.lengthSquared() < 1e-8) {
43
+ this.setVector4Value("g_windDirection", new Vector4(1, 0, 0, 0));
44
+ return;
45
+ }
46
+ v.normalize();
47
+ this.setVector4Value("g_windDirection", new Vector4(v.x, v.y, v.z, 0.0));
48
+ }
49
+ getWindDirection() {
50
+ return this.getVector4Value("g_windDirection");
51
+ }
52
+ }
53
+ export class TreeBranchMaterialPlugin extends CustomShaderMaterialPlugin {
54
+ constructor(customMaterial, shaderName) {
55
+ super(customMaterial, shaderName, 110, { TREEBRANCHMATERIAL: false });
56
+ }
57
+ isCompatible(shaderLanguage) {
58
+ return (shaderLanguage === ShaderLanguage.WGSL || shaderLanguage === ShaderLanguage.GLSL);
59
+ }
60
+ getCustomCode(shaderType, shaderLanguage) {
61
+ if (shaderType === "vertex") {
62
+ if (shaderLanguage === ShaderLanguage.WGSL) {
63
+ return {
64
+ CUSTOM_VERTEX_MAIN_END: `
65
+ // -------------------------
66
+ // TreeBranch wind bending (local-space)
67
+ // Authoring (recommended):
68
+ // vertexColor.r = bend weight (0 trunk .. 1 tips)
69
+ // vertexColor.g = phase offset noise (0..1)
70
+ // Falls back to height-based weight if vertex color missing/disabled.
71
+ // -------------------------
72
+
73
+ fn safeNormalize(v: vec3f) -> vec3f {
74
+ let lsq = dot(v, v);
75
+ if (lsq < 1e-8) { return vec3f(1.0, 0.0, 0.0); }
76
+ return v * inverseSqrt(lsq);
77
+ }
78
+
79
+ fn rotateRodrigues(p: vec3f, axis: vec3f, angle: f32) -> vec3f {
80
+ let a = safeNormalize(axis);
81
+ let c = cos(angle);
82
+ let s = sin(angle);
83
+ return p * c + cross(a, p) * s + a * dot(a, p) * (1.0 - c);
84
+ }
85
+
86
+ // Local position & normal (preferred: use normalUpdated if present in shader)
87
+ var pL: vec3f = positionUpdated;
88
+
89
+ // If COLOR attribute exists, Babylon usually provides vertexInputs.color.
90
+ // If not available, these will be 1,1,1,1 (depending on pipeline) — we guard with g_useVertexColorMask.
91
+ var bendMask: f32 = 1.0;
92
+ var phaseNoise: f32 = 0.0;
93
+ if (uniforms.g_useVertexColorMask > 0.5) {
94
+ bendMask = clamp(vertexInputs.color.r, 0.0, 1.0);
95
+ phaseNoise = vertexInputs.color.g; // 0..1
96
+ }
97
+
98
+ // Height-based fallback weight (normalized between rootY..maxHeight)
99
+ let denom = max(uniforms.g_branchMaxHeight - uniforms.g_branchRootY, 1e-3);
100
+ let h01 = clamp((pL.y - uniforms.g_branchRootY) / denom, 0.0, 1.0);
101
+
102
+ // Final per-vertex weight:
103
+ // - If using vertex colors: bendMask * smooth tip emphasis
104
+ // - Else: height-based
105
+ var w: f32 = h01;
106
+ if (uniforms.g_useVertexColorMask > 0.5) {
107
+ w = bendMask * (h01 * h01 * (3.0 - 2.0 * h01)); // smoothstep(h01)
108
+ } else {
109
+ w = h01 * h01; // a bit stiffer near base
110
+ }
111
+
112
+ // Wind direction in LOCAL space:
113
+ // We transform windDirWorld by inverse world matrix rotation (approx using finalWorld columns).
114
+ // finalWorld transforms local->world. For direction, inverse rotation is transpose of 3x3 if no shear.
115
+ let windW = safeNormalize(uniforms.g_windDirection.xyz);
116
+ let rightW = safeNormalize(finalWorld[0].xyz);
117
+ let upW = safeNormalize(finalWorld[1].xyz);
118
+ let fwdW = safeNormalize(finalWorld[2].xyz);
119
+
120
+ // Convert world dir to local by dot with basis
121
+ let windL = safeNormalize(vec3f(dot(windW, rightW), dot(windW, upW), dot(windW, fwdW)));
122
+
123
+ // Bend axis: perpendicular to up and wind, in LOCAL space
124
+ var axisL = safeNormalize(cross(vec3f(0.0, 1.0, 0.0), windL));
125
+ if (dot(axisL, axisL) < 1e-6) { axisL = vec3f(1.0, 0.0, 0.0); }
126
+
127
+ // Spatially varying phase so whole tree doesn't move as a rigid sheet
128
+ // Use local xz for coherence; optionally mod by vertexColor.g
129
+ let spatial = (pL.x + pL.z) * uniforms.g_spatialFrequency;
130
+ let phase = uniforms.g_windTime * uniforms.g_windSpeed
131
+ + spatial * uniforms.g_windStrength
132
+ + phaseNoise * 6.28318;
133
+
134
+ // Two-wave composite like Unity-ish wind
135
+ let base = sin(phase);
136
+ let gust = 0.5 * sin(phase * 1.7 + 1.2);
137
+ let sway = (base + gust) * uniforms.g_windAmount;
138
+
139
+ // Convert sway to angle (clamped)
140
+ var angle = sway * w * uniforms.g_branchMaxAngle;
141
+ angle = clamp(angle, -uniforms.g_branchMaxAngle, uniforms.g_branchMaxAngle);
142
+
143
+ // Pivot in local space
144
+ let pivotL = vec3f(0.0, uniforms.g_branchRootY, 0.0);
145
+ let relL = pL - pivotL;
146
+ let bentRelL = rotateRodrigues(relL, axisL, angle);
147
+ let bentPL = pivotL + bentRelL;
148
+
149
+ // Transform to world using finalWorld (keeps proper anchoring)
150
+ let branchWorld = (finalWorld * vec4f(bentPL, 1.0)).xyz;
151
+
152
+ // Rotate normal similarly (only if NORMAL is active)
153
+ #ifdef NORMAL
154
+ // Babylon WGSL PBR usually provides normalUpdated in local/object space
155
+ var nL: vec3f = normalize(normalUpdated);
156
+ let bentNL = rotateRodrigues(nL, axisL, angle);
157
+ // Convert to world by world 3x3
158
+ let nW = normalize(vec3f(
159
+ dot(bentNL, vec3f(finalWorld[0].x, finalWorld[0].y, finalWorld[0].z)),
160
+ dot(bentNL, vec3f(finalWorld[1].x, finalWorld[1].y, finalWorld[1].z)),
161
+ dot(bentNL, vec3f(finalWorld[2].x, finalWorld[2].y, finalWorld[2].z))
162
+ ));
163
+ vertexOutputs.vNormalW = nW;
164
+ #endif
165
+
166
+ #if defined(POSITION) || defined(BUMP)
167
+ vertexOutputs.vPositionW = branchWorld;
168
+ #endif
169
+
170
+ vertexOutputs.position = scene.viewProjection * vec4f(branchWorld, 1.0);
171
+ `
172
+ };
173
+ }
174
+ else {
175
+ return {
176
+ CUSTOM_VERTEX_DEFINITIONS: `
177
+ uniform float g_windTime;
178
+ uniform float g_windAmount;
179
+ uniform float g_windSpeed;
180
+ uniform float g_windStrength;
181
+ uniform vec4 g_windDirection;
182
+
183
+ uniform float g_branchRootY;
184
+ uniform float g_branchMaxAngle;
185
+ uniform float g_branchMaxHeight;
186
+ uniform float g_useVertexColorMask;
187
+ uniform float g_spatialFrequency;
188
+
189
+ vec3 safeNormalize(vec3 v) {
190
+ float lsq = dot(v, v);
191
+ if (lsq < 1e-8) return vec3(1.0, 0.0, 0.0);
192
+ return v * inversesqrt(lsq);
193
+ }
194
+
195
+ vec3 rotateRodrigues(vec3 p, vec3 axis, float angle) {
196
+ vec3 a = safeNormalize(axis);
197
+ float c = cos(angle);
198
+ float s = sin(angle);
199
+ return p * c + cross(a, p) * s + a * dot(a, p) * (1.0 - c);
200
+ }
201
+ `,
202
+ CUSTOM_VERTEX_MAIN_END: `
203
+ // Local/object position
204
+ vec3 pL = positionUpdated;
205
+
206
+ // Vertex color mask (recommended authoring)
207
+ float bendMask = 1.0;
208
+ float phaseNoise = 0.0;
209
+ #ifdef VERTEXCOLOR
210
+ if (g_useVertexColorMask > 0.5) {
211
+ bendMask = clamp(color.r, 0.0, 1.0);
212
+ phaseNoise = color.g;
213
+ }
214
+ #endif
215
+
216
+ float denom = max(g_branchMaxHeight - g_branchRootY, 1e-3);
217
+ float h01 = clamp((pL.y - g_branchRootY) / denom, 0.0, 1.0);
218
+
219
+ float w = h01;
220
+ if (g_useVertexColorMask > 0.5) {
221
+ // smoothstep(h01)
222
+ w = bendMask * (h01 * h01 * (3.0 - 2.0 * h01));
223
+ } else {
224
+ w = h01 * h01;
225
+ }
226
+
227
+ // Convert wind world dir to local using world basis (transpose approx)
228
+ vec3 windW = safeNormalize(g_windDirection.xyz);
229
+ vec3 rightW = safeNormalize(finalWorld[0].xyz);
230
+ vec3 upW = safeNormalize(finalWorld[1].xyz);
231
+ vec3 fwdW = safeNormalize(finalWorld[2].xyz);
232
+ vec3 windL = safeNormalize(vec3(dot(windW, rightW), dot(windW, upW), dot(windW, fwdW)));
233
+
234
+ vec3 axisL = safeNormalize(cross(vec3(0.0, 1.0, 0.0), windL));
235
+ if (dot(axisL, axisL) < 1e-6) axisL = vec3(1.0, 0.0, 0.0);
236
+
237
+ float spatial = (pL.x + pL.z) * g_spatialFrequency;
238
+ float phase = g_windTime * g_windSpeed
239
+ + spatial * g_windStrength
240
+ + phaseNoise * 6.2831853;
241
+
242
+ float base = sin(phase);
243
+ float gust = 0.5 * sin(phase * 1.7 + 1.2);
244
+ float sway = (base + gust) * g_windAmount;
245
+
246
+ float angle = clamp(sway * w * g_branchMaxAngle, -g_branchMaxAngle, g_branchMaxAngle);
247
+
248
+ vec3 pivotL = vec3(0.0, g_branchRootY, 0.0);
249
+ vec3 relL = pL - pivotL;
250
+ vec3 bentPL = pivotL + rotateRodrigues(relL, axisL, angle);
251
+
252
+ vec3 branchWorld = (finalWorld * vec4(bentPL, 1.0)).xyz;
253
+
254
+ #if defined(POSITION) || defined(BUMP)
255
+ vPositionW = branchWorld;
256
+ #endif
257
+
258
+ #ifdef NORMAL
259
+ // normalUpdated is local/object normal
260
+ vec3 nL = normalize(normalUpdated);
261
+ vec3 bentNL = rotateRodrigues(nL, axisL, angle);
262
+
263
+ // world normal from world basis (approx; assumes no non-uniform scale/shear)
264
+ vec3 nW = normalize(bentNL.x * rightW + bentNL.y * upW + bentNL.z * fwdW);
265
+ vNormalW = nW;
266
+ #endif
267
+
268
+ gl_Position = viewProjection * vec4(branchWorld, 1.0);
269
+ `
270
+ };
271
+ }
272
+ }
273
+ if (shaderType === "fragment") {
274
+ if (shaderLanguage === ShaderLanguage.WGSL) {
275
+ return {
276
+ CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `
277
+ // no-op
278
+ `
279
+ };
280
+ }
281
+ else {
282
+ return {
283
+ CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION: `
284
+ // no-op
285
+ `
286
+ };
287
+ }
288
+ }
289
+ return null;
290
+ }
291
+ getUniforms(shaderLanguage) {
292
+ const wgsl = (shaderLanguage === ShaderLanguage.WGSL);
293
+ this.vertexDefinitions = this.getCustomShaderMaterial().getCustomVertexCode(wgsl);
294
+ this.fragmentDefinitions = (wgsl === true) ? this.getCustomShaderMaterial().getCustomFragmentCode(wgsl) : null;
295
+ return this.getCustomShaderMaterial().getCustomUniforms(wgsl);
296
+ }
297
+ getSamplers(samplers) {
298
+ const customSamplers = this.getCustomShaderMaterial().getCustomSamplers();
299
+ if (customSamplers && customSamplers.length > 0)
300
+ samplers.push(...customSamplers);
301
+ }
302
+ getAttributes(attributes, scene, mesh) {
303
+ const customAttributes = this.getCustomShaderMaterial().getCustomAttributes();
304
+ if (customAttributes && customAttributes.length > 0)
305
+ attributes.push(...customAttributes);
306
+ if (attributes.indexOf("color") === -1)
307
+ attributes.push("color");
308
+ }
309
+ prepareDefines(defines, scene, mesh) {
310
+ if (!this.getIsEnabled())
311
+ return;
312
+ this.getCustomShaderMaterial().prepareCustomDefines(defines);
313
+ }
314
+ bindForSubMesh(uniformBuffer, scene, engine, subMesh) {
315
+ if (!this.getIsEnabled())
316
+ return;
317
+ this.getCustomShaderMaterial().updateCustomBindings(uniformBuffer);
318
+ }
319
+ static ExtractWindZoneOverride(properties, terrainTransform, builderInstance) {
320
+ const candidates = [];
321
+ if (properties)
322
+ candidates.push(properties);
323
+ if (properties && properties.properties)
324
+ candidates.push(properties.properties);
325
+ const meta = terrainTransform?.metadata;
326
+ if (meta)
327
+ candidates.push(meta);
328
+ if (meta && meta.toolkit)
329
+ candidates.push(meta.toolkit);
330
+ if (meta && meta.properties)
331
+ candidates.push(meta.properties);
332
+ const bmeta = builderInstance?.metadata;
333
+ if (bmeta)
334
+ candidates.push(bmeta);
335
+ if (bmeta && bmeta.toolkit)
336
+ candidates.push(bmeta.toolkit);
337
+ const tmeta = builderInstance?.transform?.metadata;
338
+ if (tmeta)
339
+ candidates.push(tmeta);
340
+ if (tmeta && tmeta.toolkit)
341
+ candidates.push(tmeta.toolkit);
342
+ let zones = null;
343
+ for (const c of candidates) {
344
+ if (!c)
345
+ continue;
346
+ if (Array.isArray(c.windzones)) {
347
+ zones = c.windzones;
348
+ break;
349
+ }
350
+ }
351
+ if (!zones || zones.length === 0)
352
+ return null;
353
+ let best = null;
354
+ let bestScore = -1e9;
355
+ for (const z of zones) {
356
+ if (!z)
357
+ continue;
358
+ const t = ((z.type != null) ? z.type : (z.mode != null ? z.mode : "")).toString().toLowerCase();
359
+ const isDirectional = (t.indexOf("direction") >= 0);
360
+ const main = (z.windMain != null) ? z.windMain : 0.0;
361
+ const score = (isDirectional ? 1000.0 : 0.0) + main;
362
+ if (score > bestScore) {
363
+ bestScore = score;
364
+ best = z;
365
+ }
366
+ }
367
+ return best;
368
+ }
369
+ }
@@ -0,0 +1,6 @@
1
+ import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
2
+ export declare class TriggerVolume {
3
+ mesh: AbstractMesh;
4
+ state: number;
5
+ }
6
+ //# sourceMappingURL=triggervolume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triggervolume.d.ts","sourceRoot":"","sources":["../src/triggervolume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,qBAAa,aAAa;IACX,IAAI,EAAE,YAAY,CAAQ;IAC1B,KAAK,EAAE,MAAM,CAAK;CAC5B"}
@@ -0,0 +1,6 @@
1
+ export class TriggerVolume {
2
+ constructor() {
3
+ this.mesh = null;
4
+ this.state = 0;
5
+ }
6
+ }
@@ -0,0 +1,20 @@
1
+ import { AdvancedDynamicTexture } from '@babylonjs/gui/2D/advancedDynamicTexture';
2
+ import { Container } from '@babylonjs/gui/2D/controls/container';
3
+ export declare class UnityDropdownMenu extends Container {
4
+ private _button;
5
+ private _popup;
6
+ private _options;
7
+ private _selectedIndex;
8
+ constructor(name?: string);
9
+ get selectedIndex(): number;
10
+ set selectedIndex(v: number);
11
+ set options(opts: Array<{
12
+ text: string;
13
+ imageSource?: string;
14
+ }>);
15
+ private _updateSelectedText;
16
+ private _rebuildOptions;
17
+ serialize(): any;
18
+ static Parse(parsedData: any, adt: AdvancedDynamicTexture, urlRewriter?: (url: string) => string): UnityDropdownMenu;
19
+ }
20
+ //# sourceMappingURL=unitydropdownmenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unitydropdownmenu.d.ts","sourceRoot":"","sources":["../src/unitydropdownmenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAMjE,qBAAa,iBAAkB,SAAQ,SAAS;IACxC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAqD;IACrE,OAAO,CAAC,cAAc,CAAa;gBAEvB,IAAI,CAAC,EAAE,MAAM;IAmEzB,IAAW,aAAa,IAAI,MAAM,CAAgC;IAClE,IAAW,aAAa,CAAC,CAAC,EAAE,MAAM,EAA0D;IAE5F,IAAW,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAGrE;IAED,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,eAAe;IAyChB,SAAS,IAAI,GAAG;WAcT,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,sBAAsB,EAAE,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,iBAAiB;CAY9H"}
@@ -0,0 +1,144 @@
1
+ import { Button } from '@babylonjs/gui/2D/controls/button';
2
+ import { Container } from '@babylonjs/gui/2D/controls/container';
3
+ import { Control } from '@babylonjs/gui/2D/controls/control';
4
+ import { TextBlock } from '@babylonjs/gui/2D/controls/textBlock';
5
+ import { StackPanel } from '@babylonjs/gui/2D/controls/stackPanel';
6
+ export class UnityDropdownMenu extends Container {
7
+ constructor(name) {
8
+ super(name || "dropdownMenu");
9
+ this._button = null;
10
+ this._popup = null;
11
+ this._options = [];
12
+ this._selectedIndex = 0;
13
+ this.width = "150px";
14
+ this.height = "30px";
15
+ this.thickness = 1;
16
+ this.cornerRadius = 3;
17
+ this.color = "#333333";
18
+ this.background = "transparent";
19
+ console.warn("DropdownMenu is a custom control and may not be fully supported in all environments.");
20
+ this._button = Button.CreateSimpleButton((this.name || "") + "_btn", "");
21
+ this._button.width = "100%";
22
+ this._button.height = "100%";
23
+ this._button.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
24
+ this._button.verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
25
+ this._button.cornerRadius = 3;
26
+ this._button.thickness = 0;
27
+ this._button.color = "#000000";
28
+ this._button.background = "#ffffff00";
29
+ const textBlock = new TextBlock((this.name || "") + "_label", "");
30
+ textBlock.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
31
+ textBlock.paddingLeft = "8px";
32
+ textBlock.resizeToFit = false;
33
+ textBlock.text = "";
34
+ textBlock.color = "#000000";
35
+ textBlock.fontSize = "14px";
36
+ textBlock.textWrapping = true;
37
+ this._button.addControl(textBlock);
38
+ const arrow = new TextBlock((this.name || "") + "_arrow", "▼");
39
+ arrow.width = "24px";
40
+ arrow.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
41
+ arrow.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_RIGHT;
42
+ arrow.paddingRight = "6px";
43
+ arrow.color = "#222222";
44
+ this._button.addControl(arrow);
45
+ this._popup = new Container((this.name || "") + "_popup");
46
+ this._popup.width = "150px";
47
+ this._popup.isVisible = false;
48
+ this._popup.background = "#ffffff";
49
+ this._popup.thickness = 1;
50
+ this._popup.cornerRadius = 3;
51
+ this._popup.zIndex = 1000;
52
+ this._popup.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
53
+ const stack = new StackPanel((this.name || "") + "_stack");
54
+ stack.isVertical = true;
55
+ this._popup.addControl(stack);
56
+ this._button.onPointerUpObservable.add(() => {
57
+ if (!this._popup)
58
+ return;
59
+ this._popup.isVisible = !this._popup.isVisible;
60
+ });
61
+ this.addControl(this._button);
62
+ this.addControl(this._popup);
63
+ }
64
+ get selectedIndex() { return this._selectedIndex; }
65
+ set selectedIndex(v) { this._selectedIndex = v; this._updateSelectedText(); }
66
+ set options(opts) {
67
+ this._options = opts || [];
68
+ this._rebuildOptions();
69
+ }
70
+ _updateSelectedText() {
71
+ if (!this._button)
72
+ return;
73
+ const label = this._button.getChildByName((this.name || "") + "_label");
74
+ if (label) {
75
+ const opt = this._options[this._selectedIndex];
76
+ label.text = opt ? opt.text : "";
77
+ }
78
+ }
79
+ _rebuildOptions() {
80
+ if (!this._popup)
81
+ return;
82
+ this._popup.dispose();
83
+ this._popup = new Container((this.name || "") + "_popup");
84
+ this._popup.width = "150px";
85
+ this._popup.isVisible = false;
86
+ this._popup.background = "#ffffff";
87
+ this._popup.thickness = 1;
88
+ this._popup.cornerRadius = 3;
89
+ this._popup.zIndex = 1000;
90
+ this._popup.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
91
+ const stack = new StackPanel((this.name || "") + "_stack");
92
+ stack.isVertical = true;
93
+ this._popup.addControl(stack);
94
+ for (let i = 0; i < this._options.length; i++) {
95
+ const o = this._options[i];
96
+ const btn = Button.CreateSimpleButton((this.name || "") + "_opt_" + i, o.text || "");
97
+ btn.width = "100%";
98
+ btn.height = "28px";
99
+ btn.thickness = 0;
100
+ btn.cornerRadius = 0;
101
+ btn.color = "#000000";
102
+ btn.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
103
+ btn.onPointerUpObservable.add(() => {
104
+ this.selectedIndex = i;
105
+ if (this._popup)
106
+ this._popup.isVisible = false;
107
+ this.onSelectionChanged && this.onSelectionChanged(i);
108
+ });
109
+ stack.addControl(btn);
110
+ }
111
+ this.addControl(this._popup);
112
+ this._updateSelectedText();
113
+ }
114
+ serialize() {
115
+ let base = {};
116
+ try {
117
+ const protoSerialize = Container.prototype.serialize;
118
+ if (typeof protoSerialize === 'function')
119
+ base = protoSerialize.call(this) || {};
120
+ }
121
+ catch (e) {
122
+ base = {};
123
+ }
124
+ base = base || {};
125
+ base.className = "UnityDropdownMenu";
126
+ base.options = this._options.map(o => ({ text: o.text, imageSource: o.imageSource }));
127
+ base.selectedIndex = this._selectedIndex;
128
+ return base;
129
+ }
130
+ static Parse(parsedData, adt, urlRewriter) {
131
+ const ctrl = new UnityDropdownMenu(parsedData.name || "dropdownMenu");
132
+ try {
133
+ if (Array.isArray(parsedData.options)) {
134
+ ctrl.options = parsedData.options.map((o) => ({ text: o.text || "", imageSource: o.imageSource }));
135
+ }
136
+ if (typeof parsedData.selectedIndex === 'number')
137
+ ctrl.selectedIndex = parsedData.selectedIndex;
138
+ }
139
+ catch (e) {
140
+ console.warn(e);
141
+ }
142
+ return ctrl;
143
+ }
144
+ }
@@ -0,0 +1,11 @@
1
+ import { AdvancedDynamicTexture } from '@babylonjs/gui/2D/advancedDynamicTexture';
2
+ import { ScrollBar } from '@babylonjs/gui/2D/controls/sliders/scrollBar';
3
+ export declare class UnityScrollBar extends ScrollBar {
4
+ private _direction;
5
+ get direction(): string;
6
+ set direction(value: string);
7
+ protected _getThumbPosition(): number;
8
+ serialize(serializationObject: any): void;
9
+ _parseFromContent(serializationObject: any, host: AdvancedDynamicTexture): void;
10
+ }
11
+ //# sourceMappingURL=unityscrollbar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unityscrollbar.d.ts","sourceRoot":"","sources":["../src/unityscrollbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAEzE,qBAAa,cAAe,SAAQ,SAAS;IACrC,OAAO,CAAC,UAAU,CAAyB;IAE3C,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED,IAAW,SAAS,CAAC,KAAK,EAAE,MAAM,EAGjC;IAED,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAkBrB,SAAS,CAAC,mBAAmB,EAAE,GAAG;IAKlC,iBAAiB,CAAC,mBAAmB,EAAE,GAAG,EAAE,IAAI,EAAE,sBAAsB;CAM3F"}
@@ -0,0 +1,38 @@
1
+ import { ScrollBar } from '@babylonjs/gui/2D/controls/sliders/scrollBar';
2
+ export class UnityScrollBar extends ScrollBar {
3
+ constructor() {
4
+ super(...arguments);
5
+ this._direction = "LeftToRight";
6
+ }
7
+ get direction() {
8
+ return this._direction;
9
+ }
10
+ set direction(value) {
11
+ this._direction = value;
12
+ this._markAsDirty();
13
+ }
14
+ _getThumbPosition() {
15
+ const normalizedValue = (this.value - this.minimum) / (this.maximum - this.minimum);
16
+ const maxPosition = this.isVertical ?
17
+ this._currentMeasure.height - this._effectiveThumbThickness :
18
+ this._currentMeasure.width - this._effectiveThumbThickness;
19
+ let position = normalizedValue * maxPosition;
20
+ if (this._direction === "RightToLeft" && !this.isVertical) {
21
+ position = maxPosition - position;
22
+ }
23
+ else if (this._direction === "TopToBottom" && this.isVertical) {
24
+ position = maxPosition - position;
25
+ }
26
+ return position;
27
+ }
28
+ serialize(serializationObject) {
29
+ super.serialize(serializationObject);
30
+ serializationObject.direction = this._direction;
31
+ }
32
+ _parseFromContent(serializationObject, host) {
33
+ super._parseFromContent(serializationObject, host);
34
+ if (serializationObject.direction) {
35
+ this._direction = serializationObject.direction;
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,4 @@
1
+ import { Slider } from '@babylonjs/gui/2D/controls/sliders/slider';
2
+ export declare class UnitySlider extends Slider {
3
+ }
4
+ //# sourceMappingURL=unityslider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unityslider.d.ts","sourceRoot":"","sources":["../src/unityslider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,qBAAa,WAAY,SAAQ,MAAM;CAElC"}
@@ -0,0 +1,3 @@
1
+ import { Slider } from '@babylonjs/gui/2D/controls/sliders/slider';
2
+ export class UnitySlider extends Slider {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { SimpleCharacterController, RecastCharacterController, CharacterController } from './scenemanager';
2
+ export type UniversalCharacterController = CharacterController | SimpleCharacterController | RecastCharacterController;
3
+ //# sourceMappingURL=universalcharactercontroller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"universalcharactercontroller.d.ts","sourceRoot":"","sources":["../src/universalcharactercontroller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE3G,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,GAAG,yBAAyB,GAAG,yBAAyB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};