@zephyr3d/editor 0.3.4 → 0.3.5

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 (64) hide show
  1. package/dist/assets/{index-DzQzWsCG.js → index-DlnbO59X.js} +2 -2
  2. package/dist/assistant/zephyr-types-index.json +9 -10
  3. package/dist/index.html +1 -1
  4. package/dist/modules/zephyr3d_backend-webgpu.js +13 -12
  5. package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
  6. package/dist/modules/zephyr3d_base.js +152 -152
  7. package/dist/modules/zephyr3d_base.js.map +1 -1
  8. package/dist/modules/zephyr3d_device.js +15 -15
  9. package/dist/modules/zephyr3d_device.js.map +1 -1
  10. package/dist/modules/zephyr3d_loaders.js +6 -6
  11. package/dist/modules/zephyr3d_loaders.js.map +1 -1
  12. package/dist/modules/zephyr3d_scene.js +1382 -1385
  13. package/dist/modules/zephyr3d_scene.js.map +1 -1
  14. package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +7 -6
  15. package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
  16. package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +6 -6
  17. package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
  18. package/dist/vendor/zephyr3d/base/dist/vfs/common.js +152 -152
  19. package/dist/vendor/zephyr3d/base/dist/vfs/common.js.map +1 -1
  20. package/dist/vendor/zephyr3d/device/dist/device.js +15 -15
  21. package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
  22. package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js +6 -6
  23. package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
  24. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +191 -194
  25. package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
  26. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js +19 -19
  27. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js.map +1 -1
  28. package/dist/vendor/zephyr3d/scene/dist/app/engine.js +131 -131
  29. package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
  30. package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js +119 -119
  31. package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js.map +1 -1
  32. package/dist/vendor/zephyr3d/scene/dist/asset/model.js +62 -62
  33. package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
  34. package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js +13 -13
  35. package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js.map +1 -1
  36. package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +201 -201
  37. package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
  38. package/dist/vendor/zephyr3d/scene/dist/index.d.ts +1 -1
  39. package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
  40. package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  41. package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js +4 -4
  42. package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js.map +1 -1
  43. package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js +11 -11
  44. package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js.map +1 -1
  45. package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +284 -284
  46. package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
  47. package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +9 -9
  48. package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
  49. package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +5 -5
  50. package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
  51. package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +7 -7
  52. package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
  53. package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -1
  54. package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
  55. package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js +45 -45
  56. package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js.map +1 -1
  57. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +275 -275
  58. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
  59. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
  60. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
  61. package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
  62. package/package.json +3 -3
  63. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
  64. package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
@@ -1,320 +0,0 @@
1
- import { Matrix4x4, Vector3 } from '@zephyr3d/base';
2
- import { getVertexFormatComponentCount } from '@zephyr3d/device';
3
- import '../../scene/scene.js';
4
- import '../../values.js';
5
- import '../../render/render_queue.js';
6
- import '../../render/primitive.js';
7
- import '../../material/shader/helper.js';
8
- import '../../material/lambert.js';
9
- import '../../material/blinn.js';
10
- import '../../material/unlit.js';
11
- import '../../material/particle.js';
12
- import '../../material/subsurfaceprofile.js';
13
- import '../../material/meshmaterial.js';
14
- import '../../material/grassmaterial.js';
15
- import '../../material/terrain-cm.js';
16
- import '../../material/pbrmr.js';
17
- import '../../material/pbrsg.js';
18
- import '../../material/mtoon.js';
19
- import '../../material/pbrblueprint.js';
20
- import '../../material/sprite.js';
21
- import '../../material/sprite_std.js';
22
- import '../../utility/blueprint/material/texture.js';
23
- import '../../render/rendergraph/forward_plus_builder.js';
24
- import '../../render/lightpass.js';
25
- import '../../render/sky.js';
26
- import '../../render/clipmap.js';
27
- import '../../shaders/atmosphere.js';
28
- import { getSceneMeshAssetBinding } from '../../scene/scene_node.js';
29
- import '../../shadow/shadowmapper.js';
30
- import '../../scene/mesh.js';
31
- import '../../scene/basesprite.js';
32
- import '../../scene/meshdrawable.js';
33
- import '../../material/msdf_text.js';
34
- import '../../scene/water.js';
35
- import '../../scene/particlesys.js';
36
- import '../../scene/batchgroup.js';
37
- import '../../scene/terrain-cm/terrain-cm.js';
38
- import '../../scene/terrain-cm/grass.js';
39
- import '../../scene/raycast_visitor.js';
40
- import { ColliderForce } from './types.js';
41
-
42
- const EPS = 1e-6;
43
- /**
44
- * Generate convex JointDynamics colliders from skinned mesh bone weights.
45
- *
46
- * @public
47
- */ function generateJointDynamicsConvexCollidersFromSkinWeights(meshes, skinBinding, bones, options = {}) {
48
- const sources = collectSourcePrimitives(meshes);
49
- const results = [];
50
- for (const bone of bones){
51
- const jointIndex = skinBinding.joints.indexOf(bone);
52
- if (jointIndex < 0) {
53
- continue;
54
- }
55
- const points = collectBonePoints(sources, skinBinding, jointIndex, options);
56
- if (points.length < (options.minVertexCount ?? 8)) {
57
- continue;
58
- }
59
- const hull = buildConvexHull(points, options.maxHullVertices ?? 48, options.margin ?? 0);
60
- if (!hull || hull.vertices.length < 4 || hull.planes.length < 4) {
61
- continue;
62
- }
63
- results.push({
64
- bone,
65
- vertexCount: points.length,
66
- hullVertexCount: hull.vertices.length,
67
- collider: {
68
- radius: 0,
69
- radiusTailScale: 1,
70
- height: 0,
71
- friction: options.friction ?? 0,
72
- isInverseCollider: options.inversed ?? false,
73
- forceType: ColliderForce.Off,
74
- convex: hull
75
- }
76
- });
77
- }
78
- return results;
79
- }
80
- function collectSourcePrimitives(meshes) {
81
- const result = [];
82
- const seen = new Set();
83
- for (const mesh of meshes){
84
- const binding = getSceneMeshAssetBinding(mesh);
85
- const subMesh = binding?.subMesh;
86
- const primitive = subMesh?.primitive ?? null;
87
- if (primitive && !seen.has(primitive)) {
88
- seen.add(primitive);
89
- result.push({
90
- primitive,
91
- subMesh
92
- });
93
- }
94
- }
95
- return result;
96
- }
97
- function collectBonePoints(sources, skinBinding, jointIndex, options) {
98
- const points = [];
99
- const weightThreshold = options.weightThreshold ?? 0.45;
100
- const dominantBoneOnly = options.dominantBoneOnly ?? true;
101
- const inverseBind = skinBinding.inverseBindMatrices[jointIndex] ?? Matrix4x4.identity();
102
- for (const source of sources){
103
- const primitive = source.primitive;
104
- const positionInfo = primitive.vertices.position;
105
- const blendIndexInfo = primitive.vertices.blendIndices;
106
- const blendWeightInfo = primitive.vertices.blendWeights;
107
- if (!positionInfo || !blendIndexInfo || !blendWeightInfo) {
108
- continue;
109
- }
110
- const positions = positionInfo.data;
111
- const blendIndices = blendIndexInfo.data;
112
- const blendWeights = blendWeightInfo.data;
113
- const posStride = getVertexFormatComponentCount(positionInfo.format);
114
- const idxStride = getVertexFormatComponentCount(blendIndexInfo.format);
115
- const weightStride = getVertexFormatComponentCount(blendWeightInfo.format);
116
- const vertexCount = Math.floor(positions.length / posStride);
117
- for(let i = 0; i < vertexCount; i++){
118
- let weight = 0;
119
- let maxWeight = -1;
120
- let maxJoint = -1;
121
- const influenceCount = Math.min(4, idxStride, weightStride);
122
- for(let k = 0; k < influenceCount; k++){
123
- const idx = Number(blendIndices[i * idxStride + k]) | 0;
124
- const w = Number(blendWeights[i * weightStride + k]) || 0;
125
- if (idx === jointIndex) {
126
- weight = Math.max(weight, w);
127
- }
128
- if (w > maxWeight) {
129
- maxWeight = w;
130
- maxJoint = idx;
131
- }
132
- }
133
- if (weight < weightThreshold || dominantBoneOnly && maxJoint !== jointIndex) {
134
- continue;
135
- }
136
- const p = new Vector3(Number(positions[i * posStride]) || 0, Number(positions[i * posStride + 1]) || 0, Number(positions[i * posStride + 2]) || 0);
137
- points.push(inverseBind.transformPointAffine(p, p));
138
- }
139
- }
140
- return uniquePoints(points);
141
- }
142
- function uniquePoints(points) {
143
- const result = [];
144
- const keys = new Set();
145
- for (const point of points){
146
- const key = `${Math.round(point.x * 100000)}:${Math.round(point.y * 100000)}:${Math.round(point.z * 100000)}`;
147
- if (!keys.has(key)) {
148
- keys.add(key);
149
- result.push(point);
150
- }
151
- }
152
- return result;
153
- }
154
- function buildConvexHull(points, maxHullVertices, margin) {
155
- const sampled = sampleSupportPoints(points, Math.max(8, maxHullVertices));
156
- if (sampled.length < 4) {
157
- return null;
158
- }
159
- const faces = bruteForceHullFaces(sampled);
160
- if (faces.length < 4) {
161
- return null;
162
- }
163
- const planes = mergePlanes(faces);
164
- if (margin > 0) {
165
- for (const plane of planes){
166
- plane.distance -= margin;
167
- }
168
- }
169
- return {
170
- vertices: sampled.map((point)=>point.clone()),
171
- planes,
172
- edges: extractHullEdges(sampled, planes)
173
- };
174
- }
175
- function sampleSupportPoints(points, maxCount) {
176
- if (points.length <= maxCount) {
177
- return [
178
- ...points
179
- ];
180
- }
181
- const dirs = buildSampleDirections(maxCount);
182
- const selected = [];
183
- const indices = new Set();
184
- for (const dir of dirs){
185
- let bestIndex = -1;
186
- let bestDot = -Infinity;
187
- for(let i = 0; i < points.length; i++){
188
- const d = Vector3.dot(points[i], dir);
189
- if (d > bestDot) {
190
- bestDot = d;
191
- bestIndex = i;
192
- }
193
- }
194
- if (bestIndex >= 0 && !indices.has(bestIndex)) {
195
- indices.add(bestIndex);
196
- selected.push(points[bestIndex]);
197
- if (selected.length >= maxCount) {
198
- break;
199
- }
200
- }
201
- }
202
- return selected.length >= 4 ? selected : [
203
- ...points.slice(0, maxCount)
204
- ];
205
- }
206
- function buildSampleDirections(maxCount) {
207
- const dirs = [
208
- new Vector3(1, 0, 0),
209
- new Vector3(-1, 0, 0),
210
- new Vector3(0, 1, 0),
211
- new Vector3(0, -1, 0),
212
- new Vector3(0, 0, 1),
213
- new Vector3(0, 0, -1)
214
- ];
215
- const rings = Math.max(4, Math.ceil(Math.sqrt(maxCount)));
216
- for(let y = 0; y < rings && dirs.length < maxCount; y++){
217
- const v = rings === 1 ? 0 : -1 + 2 * y / (rings - 1);
218
- const r = Math.sqrt(Math.max(0, 1 - v * v));
219
- for(let x = 0; x < rings * 2 && dirs.length < maxCount; x++){
220
- const a = x / (rings * 2) * Math.PI * 2;
221
- dirs.push(new Vector3(Math.cos(a) * r, v, Math.sin(a) * r));
222
- }
223
- }
224
- return dirs;
225
- }
226
- function bruteForceHullFaces(points) {
227
- const center = new Vector3();
228
- for (const point of points){
229
- Vector3.add(center, point, center);
230
- }
231
- Vector3.scale(center, 1 / points.length, center);
232
- const faces = [];
233
- const faceKeys = new Set();
234
- for(let i = 0; i < points.length - 2; i++){
235
- for(let j = i + 1; j < points.length - 1; j++){
236
- for(let k = j + 1; k < points.length; k++){
237
- const ab = Vector3.sub(points[j], points[i]);
238
- const ac = Vector3.sub(points[k], points[i]);
239
- const normal = Vector3.cross(ab, ac);
240
- const len = normal.magnitude;
241
- if (len <= EPS) {
242
- continue;
243
- }
244
- Vector3.scale(normal, 1 / len, normal);
245
- let distance = -Vector3.dot(normal, points[i]);
246
- if (Vector3.dot(normal, center) + distance > 0) {
247
- Vector3.scale(normal, -1, normal);
248
- distance = -Vector3.dot(normal, points[i]);
249
- }
250
- let valid = true;
251
- for(let p = 0; p < points.length; p++){
252
- if (p === i || p === j || p === k) {
253
- continue;
254
- }
255
- if (Vector3.dot(normal, points[p]) + distance > 1e-5) {
256
- valid = false;
257
- break;
258
- }
259
- }
260
- if (!valid) {
261
- continue;
262
- }
263
- const key = planeKey(normal, distance);
264
- if (faceKeys.has(key)) {
265
- continue;
266
- }
267
- faceKeys.add(key);
268
- faces.push({
269
- a: i,
270
- b: j,
271
- c: k,
272
- normal: normal.clone(),
273
- distance
274
- });
275
- }
276
- }
277
- }
278
- return faces;
279
- }
280
- function mergePlanes(faces) {
281
- const planes = [];
282
- for (const face of faces){
283
- if (planes.some((plane)=>Math.abs(Vector3.dot(plane.normal, face.normal) - 1) < 1e-4 && Math.abs(plane.distance - face.distance) < 1e-4)) {
284
- continue;
285
- }
286
- planes.push({
287
- normal: face.normal.clone(),
288
- distance: face.distance
289
- });
290
- }
291
- return planes;
292
- }
293
- function extractHullEdges(vertices, planes) {
294
- const result = [];
295
- const keys = new Set();
296
- for(let i = 0; i < vertices.length - 1; i++){
297
- for(let j = i + 1; j < vertices.length; j++){
298
- const sharedPlaneCount = planes.reduce((count, plane)=>{
299
- const di = Math.abs(Vector3.dot(plane.normal, vertices[i]) + plane.distance);
300
- const dj = Math.abs(Vector3.dot(plane.normal, vertices[j]) + plane.distance);
301
- return count + (di < 1e-4 && dj < 1e-4 ? 1 : 0);
302
- }, 0);
303
- if (sharedPlaneCount < 2) {
304
- continue;
305
- }
306
- const key = `${i}:${j}`;
307
- if (!keys.has(key)) {
308
- keys.add(key);
309
- result.push(i, j);
310
- }
311
- }
312
- }
313
- return result;
314
- }
315
- function planeKey(normal, distance) {
316
- return `${Math.round(normal.x * 10000)}:${Math.round(normal.y * 10000)}:${Math.round(normal.z * 10000)}:${Math.round(distance * 10000)}`;
317
- }
318
-
319
- export { generateJointDynamicsConvexCollidersFromSkinWeights };
320
- //# sourceMappingURL=convex_collider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convex_collider.js","sources":["../../../src/animation/joint_dynamics/convex_collider.ts"],"sourcesContent":["import { Matrix4x4, Vector3 } from '@zephyr3d/base';\nimport { getVertexFormatComponentCount } from '@zephyr3d/device';\nimport type { Mesh, SceneNode } from '../../scene';\nimport { getSceneMeshAssetBinding } from '../../scene';\nimport type { AssetPrimitiveInfo, AssetSubMeshData } from '../../asset';\nimport type { SkinBinding } from '../skeleton';\nimport { ColliderForce, type ColliderR, type ConvexColliderPlane } from './types';\n\n/** @public */\nexport type JointDynamicsConvexColliderGenerationOptions = {\n weightThreshold?: number;\n dominantBoneOnly?: boolean;\n maxHullVertices?: number;\n margin?: number;\n minVertexCount?: number;\n friction?: number;\n inversed?: boolean;\n};\n\n/** @public */\nexport type JointDynamicsConvexColliderGenerationResult = {\n bone: SceneNode;\n collider: ColliderR;\n vertexCount: number;\n hullVertexCount: number;\n};\n\ntype SourcePrimitive = {\n primitive: AssetPrimitiveInfo;\n subMesh?: AssetSubMeshData;\n};\n\ntype Face = {\n a: number;\n b: number;\n c: number;\n normal: Vector3;\n distance: number;\n};\n\nconst EPS = 1e-6;\n\n/**\n * Generate convex JointDynamics colliders from skinned mesh bone weights.\n *\n * @public\n */\nexport function generateJointDynamicsConvexCollidersFromSkinWeights(\n meshes: readonly Mesh[],\n skinBinding: SkinBinding,\n bones: readonly SceneNode[],\n options: JointDynamicsConvexColliderGenerationOptions = {}\n): JointDynamicsConvexColliderGenerationResult[] {\n const sources = collectSourcePrimitives(meshes);\n const results: JointDynamicsConvexColliderGenerationResult[] = [];\n for (const bone of bones) {\n const jointIndex = skinBinding.joints.indexOf(bone);\n if (jointIndex < 0) {\n continue;\n }\n const points = collectBonePoints(sources, skinBinding, jointIndex, options);\n if (points.length < (options.minVertexCount ?? 8)) {\n continue;\n }\n const hull = buildConvexHull(points, options.maxHullVertices ?? 48, options.margin ?? 0);\n if (!hull || hull.vertices.length < 4 || hull.planes.length < 4) {\n continue;\n }\n results.push({\n bone,\n vertexCount: points.length,\n hullVertexCount: hull.vertices.length,\n collider: {\n radius: 0,\n radiusTailScale: 1,\n height: 0,\n friction: options.friction ?? 0,\n isInverseCollider: options.inversed ?? false,\n forceType: ColliderForce.Off,\n convex: hull\n }\n });\n }\n return results;\n}\n\nfunction collectSourcePrimitives(meshes: readonly Mesh[]): SourcePrimitive[] {\n const result: SourcePrimitive[] = [];\n const seen = new Set<AssetPrimitiveInfo>();\n for (const mesh of meshes) {\n const binding = getSceneMeshAssetBinding(mesh);\n const subMesh = binding?.subMesh as AssetSubMeshData | undefined;\n const primitive = subMesh?.primitive ?? null;\n if (primitive && !seen.has(primitive)) {\n seen.add(primitive);\n result.push({ primitive, subMesh });\n }\n }\n return result;\n}\n\nfunction collectBonePoints(\n sources: readonly SourcePrimitive[],\n skinBinding: SkinBinding,\n jointIndex: number,\n options: JointDynamicsConvexColliderGenerationOptions\n): Vector3[] {\n const points: Vector3[] = [];\n const weightThreshold = options.weightThreshold ?? 0.45;\n const dominantBoneOnly = options.dominantBoneOnly ?? true;\n const inverseBind = skinBinding.inverseBindMatrices[jointIndex] ?? Matrix4x4.identity();\n for (const source of sources) {\n const primitive = source.primitive;\n const positionInfo = primitive.vertices.position;\n const blendIndexInfo = primitive.vertices.blendIndices;\n const blendWeightInfo = primitive.vertices.blendWeights;\n if (!positionInfo || !blendIndexInfo || !blendWeightInfo) {\n continue;\n }\n const positions = positionInfo.data;\n const blendIndices = blendIndexInfo.data;\n const blendWeights = blendWeightInfo.data;\n const posStride = getVertexFormatComponentCount(positionInfo.format);\n const idxStride = getVertexFormatComponentCount(blendIndexInfo.format);\n const weightStride = getVertexFormatComponentCount(blendWeightInfo.format);\n const vertexCount = Math.floor(positions.length / posStride);\n for (let i = 0; i < vertexCount; i++) {\n let weight = 0;\n let maxWeight = -1;\n let maxJoint = -1;\n const influenceCount = Math.min(4, idxStride, weightStride);\n for (let k = 0; k < influenceCount; k++) {\n const idx = Number(blendIndices[i * idxStride + k]) | 0;\n const w = Number(blendWeights[i * weightStride + k]) || 0;\n if (idx === jointIndex) {\n weight = Math.max(weight, w);\n }\n if (w > maxWeight) {\n maxWeight = w;\n maxJoint = idx;\n }\n }\n if (weight < weightThreshold || (dominantBoneOnly && maxJoint !== jointIndex)) {\n continue;\n }\n const p = new Vector3(\n Number(positions[i * posStride]) || 0,\n Number(positions[i * posStride + 1]) || 0,\n Number(positions[i * posStride + 2]) || 0\n );\n points.push(inverseBind.transformPointAffine(p, p));\n }\n }\n return uniquePoints(points);\n}\n\nfunction uniquePoints(points: readonly Vector3[]): Vector3[] {\n const result: Vector3[] = [];\n const keys = new Set<string>();\n for (const point of points) {\n const key = `${Math.round(point.x * 100000)}:${Math.round(point.y * 100000)}:${Math.round(point.z * 100000)}`;\n if (!keys.has(key)) {\n keys.add(key);\n result.push(point);\n }\n }\n return result;\n}\n\nfunction buildConvexHull(points: readonly Vector3[], maxHullVertices: number, margin: number) {\n const sampled = sampleSupportPoints(points, Math.max(8, maxHullVertices));\n if (sampled.length < 4) {\n return null;\n }\n const faces = bruteForceHullFaces(sampled);\n if (faces.length < 4) {\n return null;\n }\n const planes = mergePlanes(faces);\n if (margin > 0) {\n for (const plane of planes) {\n plane.distance -= margin;\n }\n }\n return {\n vertices: sampled.map((point) => point.clone()),\n planes,\n edges: extractHullEdges(sampled, planes)\n };\n}\n\nfunction sampleSupportPoints(points: readonly Vector3[], maxCount: number): Vector3[] {\n if (points.length <= maxCount) {\n return [...points];\n }\n const dirs = buildSampleDirections(maxCount);\n const selected: Vector3[] = [];\n const indices = new Set<number>();\n for (const dir of dirs) {\n let bestIndex = -1;\n let bestDot = -Infinity;\n for (let i = 0; i < points.length; i++) {\n const d = Vector3.dot(points[i], dir);\n if (d > bestDot) {\n bestDot = d;\n bestIndex = i;\n }\n }\n if (bestIndex >= 0 && !indices.has(bestIndex)) {\n indices.add(bestIndex);\n selected.push(points[bestIndex]);\n if (selected.length >= maxCount) {\n break;\n }\n }\n }\n return selected.length >= 4 ? selected : [...points.slice(0, maxCount)];\n}\n\nfunction buildSampleDirections(maxCount: number): Vector3[] {\n const dirs = [\n new Vector3(1, 0, 0),\n new Vector3(-1, 0, 0),\n new Vector3(0, 1, 0),\n new Vector3(0, -1, 0),\n new Vector3(0, 0, 1),\n new Vector3(0, 0, -1)\n ];\n const rings = Math.max(4, Math.ceil(Math.sqrt(maxCount)));\n for (let y = 0; y < rings && dirs.length < maxCount; y++) {\n const v = rings === 1 ? 0 : -1 + (2 * y) / (rings - 1);\n const r = Math.sqrt(Math.max(0, 1 - v * v));\n for (let x = 0; x < rings * 2 && dirs.length < maxCount; x++) {\n const a = (x / (rings * 2)) * Math.PI * 2;\n dirs.push(new Vector3(Math.cos(a) * r, v, Math.sin(a) * r));\n }\n }\n return dirs;\n}\n\nfunction bruteForceHullFaces(points: readonly Vector3[]): Face[] {\n const center = new Vector3();\n for (const point of points) {\n Vector3.add(center, point, center);\n }\n Vector3.scale(center, 1 / points.length, center);\n const faces: Face[] = [];\n const faceKeys = new Set<string>();\n for (let i = 0; i < points.length - 2; i++) {\n for (let j = i + 1; j < points.length - 1; j++) {\n for (let k = j + 1; k < points.length; k++) {\n const ab = Vector3.sub(points[j], points[i]);\n const ac = Vector3.sub(points[k], points[i]);\n const normal = Vector3.cross(ab, ac);\n const len = normal.magnitude;\n if (len <= EPS) {\n continue;\n }\n Vector3.scale(normal, 1 / len, normal);\n let distance = -Vector3.dot(normal, points[i]);\n if (Vector3.dot(normal, center) + distance > 0) {\n Vector3.scale(normal, -1, normal);\n distance = -Vector3.dot(normal, points[i]);\n }\n let valid = true;\n for (let p = 0; p < points.length; p++) {\n if (p === i || p === j || p === k) {\n continue;\n }\n if (Vector3.dot(normal, points[p]) + distance > 1e-5) {\n valid = false;\n break;\n }\n }\n if (!valid) {\n continue;\n }\n const key = planeKey(normal, distance);\n if (faceKeys.has(key)) {\n continue;\n }\n faceKeys.add(key);\n faces.push({ a: i, b: j, c: k, normal: normal.clone(), distance });\n }\n }\n }\n return faces;\n}\n\nfunction mergePlanes(faces: readonly Face[]): ConvexColliderPlane[] {\n const planes: ConvexColliderPlane[] = [];\n for (const face of faces) {\n if (\n planes.some(\n (plane) =>\n Math.abs(Vector3.dot(plane.normal, face.normal) - 1) < 1e-4 &&\n Math.abs(plane.distance - face.distance) < 1e-4\n )\n ) {\n continue;\n }\n planes.push({ normal: face.normal.clone(), distance: face.distance });\n }\n return planes;\n}\n\nfunction extractHullEdges(\n vertices: readonly Vector3[],\n planes: readonly ConvexColliderPlane[]\n): number[] {\n const result: number[] = [];\n const keys = new Set<string>();\n for (let i = 0; i < vertices.length - 1; i++) {\n for (let j = i + 1; j < vertices.length; j++) {\n const sharedPlaneCount = planes.reduce((count, plane) => {\n const di = Math.abs(Vector3.dot(plane.normal, vertices[i]) + plane.distance);\n const dj = Math.abs(Vector3.dot(plane.normal, vertices[j]) + plane.distance);\n return count + (di < 1e-4 && dj < 1e-4 ? 1 : 0);\n }, 0);\n if (sharedPlaneCount < 2) {\n continue;\n }\n const key = `${i}:${j}`;\n if (!keys.has(key)) {\n keys.add(key);\n result.push(i, j);\n }\n }\n }\n return result;\n}\n\nfunction planeKey(normal: Vector3, distance: number): string {\n return `${Math.round(normal.x * 10000)}:${Math.round(normal.y * 10000)}:${Math.round(normal.z * 10000)}:${Math.round(distance * 10000)}`;\n}\n"],"names":["EPS","generateJointDynamicsConvexCollidersFromSkinWeights","meshes","skinBinding","bones","options","sources","collectSourcePrimitives","results","bone","jointIndex","joints","indexOf","points","collectBonePoints","length","minVertexCount","hull","buildConvexHull","maxHullVertices","margin","vertices","planes","push","vertexCount","hullVertexCount","collider","radius","radiusTailScale","height","friction","isInverseCollider","inversed","forceType","ColliderForce","Off","convex","result","seen","Set","mesh","binding","getSceneMeshAssetBinding","subMesh","primitive","has","add","weightThreshold","dominantBoneOnly","inverseBind","inverseBindMatrices","Matrix4x4","identity","source","positionInfo","position","blendIndexInfo","blendIndices","blendWeightInfo","blendWeights","positions","data","posStride","getVertexFormatComponentCount","format","idxStride","weightStride","Math","floor","i","weight","maxWeight","maxJoint","influenceCount","min","k","idx","Number","w","max","p","Vector3","transformPointAffine","uniquePoints","keys","point","key","round","x","y","z","sampled","sampleSupportPoints","faces","bruteForceHullFaces","mergePlanes","plane","distance","map","clone","edges","extractHullEdges","maxCount","dirs","buildSampleDirections","selected","indices","dir","bestIndex","bestDot","Infinity","d","dot","slice","rings","ceil","sqrt","v","r","a","PI","cos","sin","center","scale","faceKeys","j","ab","sub","ac","normal","cross","len","magnitude","valid","planeKey","b","c","face","some","abs","sharedPlaneCount","reduce","count","di","dj"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,GAAM,GAAA,IAAA;AAEZ;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