t3d-ez.gl 0.0.2 → 0.0.4

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 (59) hide show
  1. package/dist/core/Addons/RaycasterAide.cjs.js +1 -0
  2. package/dist/core/Addons/RaycasterAide.esm.js +1 -0
  3. package/dist/core/Controls/TTControls/TTControls.cjs.js +1 -1
  4. package/dist/core/Controls/TTControls/TTControls.esm.js +1 -1
  5. package/dist/core/Map/index.cjs.js +1 -1
  6. package/dist/core/Map/index.esm.js +1 -1
  7. package/dist/core/Resource/loaders.cjs.js +1 -1
  8. package/dist/core/Resource/loaders.esm.js +1 -1
  9. package/dist/core/WebGLEngine/index.cjs.js +1 -1
  10. package/dist/core/WebGLEngine/index.esm.js +1 -1
  11. package/dist/helpers/AxesAddHelper.cjs.js +1 -0
  12. package/dist/helpers/AxesAddHelper.esm.js +1 -0
  13. package/dist/helpers/T3DEzViewportGizmo.cjs.js +1 -0
  14. package/dist/helpers/T3DEzViewportGizmo.esm.js +1 -0
  15. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.core.cjs.js +1 -1
  16. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.core.esm.js +1 -1
  17. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.module.cjs.js +1 -1
  18. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.module.esm.js +1 -1
  19. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.cjs.js +1 -0
  20. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/Line2.esm.js +1 -0
  21. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineGeometry.cjs.js +1 -0
  22. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineGeometry.esm.js +1 -0
  23. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineMaterial.cjs.js +1 -0
  24. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineMaterial.esm.js +1 -0
  25. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegments2.cjs.js +1 -0
  26. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegments2.esm.js +1 -0
  27. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.cjs.js +1 -0
  28. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.esm.js +1 -0
  29. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/utils/BufferGeometryUtils.cjs.js +1 -1
  30. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/utils/BufferGeometryUtils.esm.js +1 -1
  31. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/src/math/MathUtils.cjs.js +1 -0
  32. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/src/math/MathUtils.esm.js +1 -0
  33. package/dist/package.json +1 -1
  34. package/dist/t3d-ez.gl.cjs.js +1 -1
  35. package/dist/t3d-ez.gl.esm.js +1 -1
  36. package/dist/types/core/Addons/RaycasterAide.d.ts +12 -0
  37. package/dist/types/core/Addons/index.d.ts +1 -0
  38. package/dist/types/core/Controls/index.d.ts +4 -4
  39. package/dist/types/core/MarkerHtmlUI/index.d.ts +3 -3
  40. package/dist/types/core/PostProcessor/index.d.ts +5 -5
  41. package/dist/types/core/Resource/ResourceManager.d.ts +4 -4
  42. package/dist/types/core/Resource/loaders.d.ts +2 -2
  43. package/dist/types/core/WebGLEngine/index.d.ts +9 -9
  44. package/dist/types/core/WebGLEngine/types/index.d.ts +3 -3
  45. package/dist/types/core/index.d.ts +1 -1
  46. package/dist/types/helpers/AxesAddHelper.d.ts +6 -0
  47. package/dist/types/helpers/T3DEzViewportGizmo.d.ts +271 -0
  48. package/dist/types/helpers/index.d.ts +2 -0
  49. package/dist/types/utils/FpsMeter/index.d.ts +3 -3
  50. package/dist/types/utils/index.d.ts +7 -7
  51. package/package.json +1 -1
  52. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/RGBELoader.cjs.js +0 -1
  53. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/loaders/RGBELoader.esm.js +0 -1
  54. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/physics/AmmoPhysics.cjs.js +0 -1
  55. package/dist/node_modules/.pnpm/three@0.182.0/node_modules/three/examples/jsm/physics/AmmoPhysics.esm.js +0 -1
  56. package/dist/types/core/Physics/index.d.ts +0 -1
  57. /package/dist/core/Map/{extrudeMap.cjs.js → ExtrudeMap.cjs.js} +0 -0
  58. /package/dist/core/Map/{extrudeMap.esm.js → ExtrudeMap.esm.js} +0 -0
  59. /package/dist/types/core/Map/{extrudeMap.d.ts → ExtrudeMap.d.ts} +0 -0
@@ -0,0 +1,271 @@
1
+ import { Vector3, Vector2, Object3D, Quaternion, Clock, Scene, Camera, WebGLRenderer } from 'three';
2
+ /**
3
+ * ViewportGizmo is a 3D camera orientation controller that provides a visual interface
4
+ * for changing the camera's viewing angle. It creates a widget that shows the current
5
+ * camera orientation and allows direct manipulation of the view through clicking or dragging.
6
+ *
7
+ * @fires ViewportGizmo#start - Fired when a view change interaction begins
8
+ * @fires ViewportGizmo#change - Fired during view changes
9
+ * @fires ViewportGizmo#end - Fired when a view change interaction ends
10
+ *
11
+ * @extends Object3D
12
+ */
13
+ declare class T3DEzViewportGizmo extends Object3D {
14
+ /** Whether the gizmo is currently active and responding to user input */
15
+ enabled: boolean;
16
+ /** The camera being controlled by this gizmo */
17
+ camera: Camera;
18
+ /** The WebGLRenderer rendering the gizmo */
19
+ renderer: WebGLRenderer;
20
+ /** The configuration options */
21
+ options: any;
22
+ /** The point around which the camera rotates */
23
+ target: Vector3;
24
+ /** Whether view changes should be animated */
25
+ animated: boolean;
26
+ /** The speed of view change animations. Higher values result in faster animations */
27
+ speed: number;
28
+ /**
29
+ * Indicates whether the gizmo is currently being animated or not,
30
+ * Useful when interacting with other camera controllers
31
+ *
32
+ * @readonly This value is set internally.
33
+ **/
34
+ animating: boolean;
35
+ _options: any;
36
+ _intersections: any;
37
+ _background: null;
38
+ _viewport: number[];
39
+ _originalViewport: number[];
40
+ _originalScissor: number[];
41
+ _scene: Scene<import("three").Object3DEventMap>;
42
+ _camera: any;
43
+ _container: any;
44
+ _domElement: any;
45
+ _domRect: any;
46
+ _dragging: boolean;
47
+ calc_distance: number;
48
+ _clock: Clock;
49
+ _targetQuaternion: Quaternion;
50
+ _quaternionStart: Quaternion;
51
+ _quaternionEnd: Quaternion;
52
+ _pointerStart: Vector2;
53
+ _focus: Object3D | null;
54
+ _placement: any;
55
+ _controls: any;
56
+ _controlsListeners: any;
57
+ /**
58
+ * Creates a new ViewportGizmo instance.
59
+ *
60
+ * @param camera - The camera to be controlled by this gizmo
61
+ * @param renderer - The WebGL renderer used to render the scene
62
+ * @param options - {@link GizmoOptions}, Configuration options for the gizmo.
63
+ * @param options.container - Parent element for the gizmo. Can be an HTMLElement or a CSS selector string
64
+ * @param options.type - The gizmo configuration type. Either 'sphere' or 'cube', defaults to 'sphere'
65
+ * @param options.size - Size of the gizmo widget in pixels. Defaults to 128
66
+ * @param options.placement - Position of the gizmo in the viewport
67
+ * Options include:
68
+ * - `"top-left"`
69
+ * - `"top-center"`
70
+ * - `"top-right"`
71
+ * - `"center-left"`
72
+ * - `"center-center"`
73
+ * - `"center-right"`
74
+ * - `"bottom-left"`
75
+ * - `"bottom-center"`
76
+ * - `"bottom-right"`
77
+ * @param options.offset - Offset of the gizmo from container edges in pixels
78
+ * @param options.offset.left - Offset from the left edge
79
+ * @param options.offset.top - Offset from the top edge
80
+ * @param options.offset.right - Offset from the right edge
81
+ * @param options.offset.bottom - Offset from the bottom edge
82
+ * @param options.animated - Whether view changes should be animated. Defaults to true
83
+ * @param options.speed - Animation speed multiplier. Defaults to 1
84
+ * @param options.resolution - Texture resolution. Defaults to 64 for sphere, 128 for cube
85
+ * @param options.lineWidth - Width of the axes lines in pixels
86
+ * @param options.id - HTML `id` attribute for the gizmo container
87
+ * @param options.className - HTML `class` attribute for the gizmo container
88
+ * @param options.font - Font configuration for axis labels
89
+ * @param options.font.family - Font family for axis labels
90
+ * @param options.font.weight - Font weight for axis labels
91
+ * @param options.background - Configuration for the background sphere/cube
92
+ * @param options.background.enabled - Whether to display the background
93
+ * @param options.background.color - Color of the background in normal state
94
+ * @param options.background.opacity - Opacity of the background in normal state
95
+ * @param options.background.hover.color - Color of the background when hovered
96
+ * @param options.background.hover.opacity - Opacity of the background when hovered
97
+ * @param options.corners - Configuration for corner indicators
98
+ * @param options.corners.enabled - Whether to display corner indicators
99
+ * @param options.corners.color - Base color of corner indicators
100
+ * @param options.corners.opacity - Opacity of corner indicators
101
+ * @param options.corners.scale - Scale multiplier for corner indicators
102
+ * @param options.corners.radius - Radius of corner indicators
103
+ * @param options.corners.smoothness - Smoothness of corner indicators
104
+ * @param options.corners.hover.color - Color of corner indicators when hovered
105
+ * @param options.corners.hover.opacity - Opacity of corner indicators when hovered
106
+ * @param options.corners.hover.scale - Scale of corner indicators when hovered
107
+ * @param options.edges - Configuration for edge indicators
108
+ * @param options.edges.enabled - Whether to display edge indicators
109
+ * @param options.edges.color - Base color of edge indicators
110
+ * @param options.edges.opacity - Opacity of edge indicators
111
+ * @param options.edges.scale - Scale multiplier for edge indicators
112
+ * @param options.edges.radius - Radius of edge indicators
113
+ * @param options.edges.smoothness - Smoothness of edge indicators
114
+ * @param options.edges.hover.color - Color of edge indicators when hovered
115
+ * @param options.edges.hover.opacity - Opacity of edge indicators when hovered
116
+ * @param options.edges.hover.scale - Scale of edge indicators when hovered
117
+ * @param options.x - Configuration for positive X axis/face
118
+ * @param options.y - Configuration for positive Y axis/face
119
+ * @param options.z - Configuration for positive Z axis/face
120
+ * @param options.nx - Configuration for negative X axis/face
121
+ * @param options.ny - Configuration for negative Y axis/face
122
+ * @param options.nz - Configuration for negative Z axis/face
123
+ *
124
+ * @remarks Axis-specific configuration can also use alias names for cube mode:
125
+ * - `right` (same as `x`)
126
+ * - `left` (same as `nx`)
127
+ * - `top` (same as `y`)
128
+ * - `bottom` (same as `ny`)
129
+ * - `front` (same as `z`)
130
+ * - `back` (same as `nz`)
131
+ *
132
+ * For each axis/face configuration, the following options are available:
133
+ * @param options.AXIS.enabled - Whether to draw the axis
134
+ * @param options.AXIS.label - Custom text label for the axis
135
+ * @param options.AXIS.opacity - Axis opacity
136
+ * @param options.AXIS.scale - Scale multiplier for indicator size
137
+ * @param options.AXIS.line - Whether to draw the axis line
138
+ * @param options.AXIS.color - Axis indicator background color
139
+ * @param options.AXIS.labelColor - Axis label color
140
+ * @param options.AXIS.border.size - Border size around the axis indicator
141
+ * @param options.AXIS.border.color - Border color around the axis indicator
142
+ * @param options.AXIS.hover.color - Fill color on hover
143
+ * @param options.AXIS.hover.labelColor - Label text color on hover
144
+ * @param options.AXIS.hover.opacity - Opacity when hovered
145
+ * @param options.AXIS.hover.scale - Indicator scale when hovered
146
+ * @param options.AXIS.hover.border.size - Hover border size
147
+ * @param options.AXIS.hover.border.color - Hover border color
148
+ */
149
+ constructor(camera: Camera, renderer: WebGLRenderer, options?: {});
150
+ /** Gets the current placement of the gizmo relative to its container. */
151
+ get placement(): any;
152
+ /**
153
+ * Sets and update the placement of the gizmo relative to its container.
154
+ *
155
+ * @param placement - The new placement position
156
+ */
157
+ set placement(placement: any);
158
+ /**
159
+ * Regenerates the gizmo with the new options.
160
+ *
161
+ * @remarks
162
+ * - Not recommended for use in real-time rendering or animation loops
163
+ * - Provides a way to completely rebuild the gizmo with new options
164
+ * - Can be computationally expensive, so use sparingly
165
+ */
166
+ set(options?: {}): this;
167
+ /**
168
+ * Renders the gizmo to the screen.
169
+ * This method handles viewport and scissor management to ensure the gizmo
170
+ * renders correctly without affecting the main scene rendering.
171
+ *
172
+ * @returns The gizmo instance for method chaining
173
+ */
174
+ render(): this;
175
+ /**
176
+ * Updates the gizmo's DOM-related properties based on its current position
177
+ * and size in the document.
178
+ *
179
+ * @returns The gizmo instance for method chaining
180
+ */
181
+ domUpdate(): this;
182
+ /**
183
+ * Updates the gizmo's orientation to match the current camera orientation.
184
+ *
185
+ * @returns The gizmo instance for method chaining
186
+ */
187
+ cameraUpdate(): this;
188
+ /**
189
+ * Performs a complete update of the gizmo, including both DOM and camera-related updates.
190
+ *
191
+ * @param controls - Internal. Set to `false` if the update event comes from the attached controls.
192
+ *
193
+ * @returns The gizmo instance for method chaining
194
+ */
195
+ update(controls?: boolean): this;
196
+ /**
197
+ * Connects OrbitControls with the gizmo, handling interaction states and updates.
198
+ * Automatically detaches any previously attached controls.
199
+ *
200
+ * @param controls - The scene's {@link https://threejs.org/docs/#examples/en/controls/OrbitControls OrbitControls}
201
+ */
202
+ attachControls(controls: any): this;
203
+ /** Removes all control event listeners and references. Safe to call multiple times. */
204
+ detachControls(): this | undefined;
205
+ /** Cleans up all resources including geometries, materials, textures, and event listeners. */
206
+ dispose(): void;
207
+ /**
208
+ * Updates the gizmo's orientation either based on the camera or internal state.
209
+ *
210
+ * @private
211
+ * @param fromCamera - Whether to update based on camera orientation (true) or internal state (false)
212
+ */
213
+ _updateOrientation(fromCamera?: boolean): void;
214
+ /**
215
+ * Handles the animation of camera position and orientation changes.
216
+ *
217
+ * @private
218
+ */
219
+ _animate(): void;
220
+ /**
221
+ * Sets the camera orientation to look at the target from a specific axis.
222
+ *
223
+ * @private
224
+ * @param position - The axis point position
225
+ */
226
+ setOrientation(position: any): void;
227
+ /**
228
+ * Handles the pointer down event for starting drag operations.
229
+ *
230
+ * @private
231
+ * @param e - The pointer event
232
+ */
233
+ _onPointerDown(e: MouseEvent): void;
234
+ /**
235
+ * Converts the input-coordinates from the standard Y-axis up to what is set in Object3D.DEFAULT_UP.
236
+ *
237
+ * @private
238
+ * @param target - The target Vector3 to be converted
239
+ * @param isSpherical - Whether or not the coordinates are for a sphere
240
+ * @returns The converted coordinates
241
+ */
242
+ coordinateConversion(target: any, isSpherical?: boolean): any;
243
+ /**
244
+ * Handles pointer move events for hover effects and drag operations.
245
+ *
246
+ * @private
247
+ * @param e - The pointer event
248
+ */
249
+ _onPointerMove(e: MouseEvent): void;
250
+ /**
251
+ * Handles pointer leave events to reset hover states.
252
+ *
253
+ * @private
254
+ */
255
+ _onPointerLeave(): void;
256
+ /**
257
+ * Handles click events for axis selection.
258
+ *
259
+ * @private
260
+ * @param e - The pointer event
261
+ */
262
+ _handleClick(e: MouseEvent): void;
263
+ /**
264
+ * Handles hover effects for interactive elements.
265
+ *
266
+ * @private
267
+ * @param e - The pointer event
268
+ */
269
+ _handleHover(e: MouseEvent): void;
270
+ }
271
+ export { T3DEzViewportGizmo };
@@ -1 +1,3 @@
1
1
  export { InfiniteGridHelper } from './InfiniteGridHelper';
2
+ export { AxesAddHelper } from './AxesAddHelper';
3
+ export { T3DEzViewportGizmo } from './T3DEzViewportGizmo';
@@ -1,8 +1,8 @@
1
1
  import Stats from "three/examples/jsm/libs/stats.module.js";
2
- import { IPotatoEngine } from "../../core/WebGLEngine/types/index";
2
+ import { IT3dEZEngine } from "../../core/WebGLEngine/types/index";
3
3
  type PerStatsType = {
4
4
  container?: HTMLElement;
5
- engine?: IPotatoEngine;
5
+ engine?: IT3dEZEngine;
6
6
  };
7
7
  export declare class PerformanceStats {
8
8
  name: string;
@@ -11,6 +11,6 @@ export declare class PerformanceStats {
11
11
  container: HTMLElement;
12
12
  constructor(options?: PerStatsType);
13
13
  init(container: HTMLElement): void;
14
- updateEngine(engine: IPotatoEngine): void;
14
+ updateEngine(engine: IT3dEZEngine): void;
15
15
  }
16
16
  export {};
@@ -1,9 +1,9 @@
1
1
  import { Logger } from "./Logger";
2
2
  export * from "./FpsMeter/index";
3
3
  import { Texture } from "three";
4
- import { PotatoEngine } from "../core/WebGLEngine";
4
+ import { T3dEZEngine } from "../core/WebGLEngine/index";
5
5
  import * as THREE from 'three';
6
- export declare function setDefaultEnvironment(engine: PotatoEngine): void;
6
+ export declare function setDefaultEnvironment(engine: T3dEZEngine): void;
7
7
  /**
8
8
  * 节流函数(定时器实现)
9
9
  * @param func 需要节流的函数
@@ -17,7 +17,7 @@ export declare function throttleTimer(func: (...args: any[]) => void, delay: num
17
17
  * @param engine VirtuEngine
18
18
  * @param isBg boolean
19
19
  */
20
- export declare function loadHdrToScene(texture: Texture, engine: PotatoEngine, isBg?: boolean): Texture<unknown> | null;
20
+ export declare function loadHdrToScene(texture: Texture, engine: T3dEZEngine, isBg?: boolean): Texture<unknown> | null;
21
21
  export declare function getContainerElement(cube: HTMLElement | string): HTMLElement;
22
22
  /**
23
23
  * 相机移动动画
@@ -28,7 +28,7 @@ export declare function getContainerElement(cube: HTMLElement | string): HTMLEle
28
28
  * @param startCallback
29
29
  * @param comleteCallback
30
30
  */
31
- export declare function flyTo(engine: PotatoEngine, position?: THREE.Vector3, target?: THREE.Vector3, index?: number, ease?: string, startCallback?: () => void, comleteCallback?: () => void): void;
31
+ export declare function flyTo(engine: T3dEZEngine, position?: THREE.Vector3, target?: THREE.Vector3, index?: number, ease?: string, startCallback?: () => void, comleteCallback?: () => void): void;
32
32
  /**
33
33
  * 相机移动动画
34
34
  * @param position
@@ -45,7 +45,7 @@ export declare function flyTo(engine: PotatoEngine, position?: THREE.Vector3, ta
45
45
  * @param disScale
46
46
  * @returns
47
47
  */
48
- export declare function focusTo(engine: PotatoEngine, target: THREE.Object3D | undefined | null, duration?: number): void;
49
- export declare function disposeApp(engine: PotatoEngine | null): void;
50
- export declare function destroyModel(engine: PotatoEngine | null, model: THREE.Object3D): void;
48
+ export declare function focusTo(engine: T3dEZEngine, target: THREE.Object3D | undefined | null, duration?: number): void;
49
+ export declare function disposeApp(engine: T3dEZEngine | null): void;
50
+ export declare function destroyModel(engine: T3dEZEngine | null, model: THREE.Object3D): void;
51
51
  export { Logger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "t3d-ez.gl",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "./dist/t3d-ez.gl.cjs.js",
6
6
  "module": "./dist/t3d-ez.gl.esm.js",
@@ -1 +0,0 @@
1
- "use strict";var r=require("./HDRLoader.cjs.js");class e extends r.HDRLoader{constructor(r){super(r)}}exports.RGBELoader=e;
@@ -1 +0,0 @@
1
- import{HDRLoader as r}from"./HDRLoader.esm.js";class s extends r{constructor(r){super(r)}}export{s as RGBELoader};
@@ -1 +0,0 @@
1
- "use strict";function t(t,e,n,o){const i=e.x(),s=e.y(),r=e.z(),a=e.w(),c=i+i,d=s+s,u=r+r,l=i*c,w=i*d,f=i*u,y=s*d,g=s*u,h=r*u,b=a*c,m=a*d,p=a*u;n[o+0]=1-(y+h),n[o+1]=w+p,n[o+2]=f-m,n[o+3]=0,n[o+4]=w-p,n[o+5]=1-(l+h),n[o+6]=g+b,n[o+7]=0,n[o+8]=f+m,n[o+9]=g-b,n[o+10]=1-(l+y),n[o+11]=0,n[o+12]=t.x(),n[o+13]=t.y(),n[o+14]=t.z(),n[o+15]=1}exports.AmmoPhysics=async function(){if("Ammo"in window==!1)return;const e=await Ammo(),n=new e.btDefaultCollisionConfiguration,o=new e.btCollisionDispatcher(n),i=new e.btDbvtBroadphase,s=new e.btSequentialImpulseConstraintSolver,r=new e.btDiscreteDynamicsWorld(o,i,s,n);r.setGravity(new e.btVector3(0,-9.8,0));const a=new e.btTransform,c=[],d=new WeakMap;function u(t,n=0,o=0){const i=function(t){const n=t.parameters;if("BoxGeometry"===t.type){const t=void 0!==n.width?n.width/2:.5,o=void 0!==n.height?n.height/2:.5,i=void 0!==n.depth?n.depth/2:.5,s=new e.btBoxShape(new e.btVector3(t,o,i));return s.setMargin(.05),s}if("SphereGeometry"===t.type||"IcosahedronGeometry"===t.type){const t=void 0!==n.radius?n.radius:1,o=new e.btSphereShape(t);return o.setMargin(.05),o}return null}(t.geometry);null!==i&&(t.isInstancedMesh?function(t,n,o,i){const s=t.instanceMatrix.array,a=[];for(let c=0;c<t.count;c++){const t=16*c,d=new e.btTransform;d.setFromOpenGLMatrix(s.slice(t,t+16));const u=new e.btDefaultMotionState(d),l=new e.btVector3(0,0,0);n.calculateLocalInertia(o,l);const w=new e.btRigidBodyConstructionInfo(o,u,n,l);w.set_m_restitution(i);const f=new e.btRigidBody(w);r.addRigidBody(f),a.push(f)}o>0&&(c.push(t),d.set(t,a))}(t,i,n,o):t.isMesh&&function(t,n,o,i){const s=t.position,a=t.quaternion,u=new e.btTransform;u.setIdentity(),u.setOrigin(new e.btVector3(s.x,s.y,s.z)),u.setRotation(new e.btQuaternion(a.x,a.y,a.z,a.w));const l=new e.btDefaultMotionState(u),w=new e.btVector3(0,0,0);n.calculateLocalInertia(o,w);const f=new e.btRigidBodyConstructionInfo(o,l,n,w);f.set_m_restitution(i);const y=new e.btRigidBody(f);r.addRigidBody(y),o>0&&(c.push(t),d.set(t,y))}(t,i,n,o))}let l=0;return setInterval(function(){const e=performance.now();if(l>0){const n=(e-l)/1e3;r.stepSimulation(n,10);for(let e=0,n=c.length;e<n;e++){const n=c[e];if(n.isInstancedMesh){const e=n.instanceMatrix.array,o=d.get(n);for(let n=0;n<o.length;n++){o[n].getMotionState().getWorldTransform(a);t(a.getOrigin(),a.getRotation(),e,16*n)}n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere()}else if(n.isMesh){d.get(n).getMotionState().getWorldTransform(a);const t=a.getOrigin(),e=a.getRotation();n.position.set(t.x(),t.y(),t.z()),n.quaternion.set(e.x(),e.y(),e.z(),e.w())}}}l=e},1e3/60),{addScene:function(t){t.traverse(function(t){if(t.isMesh){const e=t.userData.physics;e&&u(t,e.mass,e.restitution)}})},addMesh:u,setMeshPosition:function(t,n,o=0){if(t.isInstancedMesh){const i=d.get(t)[o];i.setAngularVelocity(new e.btVector3(0,0,0)),i.setLinearVelocity(new e.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new e.btVector3(n.x,n.y,n.z)),i.setWorldTransform(a)}else if(t.isMesh){const o=d.get(t);o.setAngularVelocity(new e.btVector3(0,0,0)),o.setLinearVelocity(new e.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new e.btVector3(n.x,n.y,n.z)),o.setWorldTransform(a)}}}};
@@ -1 +0,0 @@
1
- async function t(){if("Ammo"in window==!1)return;const t=await Ammo(),n=new t.btDefaultCollisionConfiguration,o=new t.btCollisionDispatcher(n),i=new t.btDbvtBroadphase,s=new t.btSequentialImpulseConstraintSolver,r=new t.btDiscreteDynamicsWorld(o,i,s,n);r.setGravity(new t.btVector3(0,-9.8,0));const a=new t.btTransform;const c=[],d=new WeakMap;function u(e,n=0,o=0){const i=function(e){const n=e.parameters;if("BoxGeometry"===e.type){const e=void 0!==n.width?n.width/2:.5,o=void 0!==n.height?n.height/2:.5,i=void 0!==n.depth?n.depth/2:.5,s=new t.btBoxShape(new t.btVector3(e,o,i));return s.setMargin(.05),s}if("SphereGeometry"===e.type||"IcosahedronGeometry"===e.type){const e=void 0!==n.radius?n.radius:1,o=new t.btSphereShape(e);return o.setMargin(.05),o}return null}(e.geometry);null!==i&&(e.isInstancedMesh?function(e,n,o,i){const s=e.instanceMatrix.array,a=[];for(let c=0;c<e.count;c++){const e=16*c,d=new t.btTransform;d.setFromOpenGLMatrix(s.slice(e,e+16));const u=new t.btDefaultMotionState(d),l=new t.btVector3(0,0,0);n.calculateLocalInertia(o,l);const w=new t.btRigidBodyConstructionInfo(o,u,n,l);w.set_m_restitution(i);const f=new t.btRigidBody(w);r.addRigidBody(f),a.push(f)}o>0&&(c.push(e),d.set(e,a))}(e,i,n,o):e.isMesh&&function(e,n,o,i){const s=e.position,a=e.quaternion,u=new t.btTransform;u.setIdentity(),u.setOrigin(new t.btVector3(s.x,s.y,s.z)),u.setRotation(new t.btQuaternion(a.x,a.y,a.z,a.w));const l=new t.btDefaultMotionState(u),w=new t.btVector3(0,0,0);n.calculateLocalInertia(o,w);const f=new t.btRigidBodyConstructionInfo(o,l,n,w);f.set_m_restitution(i);const g=new t.btRigidBody(f);r.addRigidBody(g),o>0&&(c.push(e),d.set(e,g))}(e,i,n,o))}let l=0;return setInterval(function(){const t=performance.now();if(l>0){const n=(t-l)/1e3;r.stepSimulation(n,10);for(let t=0,n=c.length;t<n;t++){const n=c[t];if(n.isInstancedMesh){const t=n.instanceMatrix.array,o=d.get(n);for(let n=0;n<o.length;n++){o[n].getMotionState().getWorldTransform(a);e(a.getOrigin(),a.getRotation(),t,16*n)}n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere()}else if(n.isMesh){d.get(n).getMotionState().getWorldTransform(a);const t=a.getOrigin(),e=a.getRotation();n.position.set(t.x(),t.y(),t.z()),n.quaternion.set(e.x(),e.y(),e.z(),e.w())}}}l=t},1e3/60),{addScene:function(t){t.traverse(function(t){if(t.isMesh){const e=t.userData.physics;e&&u(t,e.mass,e.restitution)}})},addMesh:u,setMeshPosition:function(e,n,o=0){if(e.isInstancedMesh){const i=d.get(e)[o];i.setAngularVelocity(new t.btVector3(0,0,0)),i.setLinearVelocity(new t.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new t.btVector3(n.x,n.y,n.z)),i.setWorldTransform(a)}else if(e.isMesh){const o=d.get(e);o.setAngularVelocity(new t.btVector3(0,0,0)),o.setLinearVelocity(new t.btVector3(0,0,0)),a.setIdentity(),a.setOrigin(new t.btVector3(n.x,n.y,n.z)),o.setWorldTransform(a)}}}}function e(t,e,n,o){const i=e.x(),s=e.y(),r=e.z(),a=e.w(),c=i+i,d=s+s,u=r+r,l=i*c,w=i*d,f=i*u,g=s*d,y=s*u,h=r*u,b=a*c,p=a*d,m=a*u;n[o+0]=1-(g+h),n[o+1]=w+m,n[o+2]=f-p,n[o+3]=0,n[o+4]=w-m,n[o+5]=1-(l+h),n[o+6]=y+b,n[o+7]=0,n[o+8]=f+p,n[o+9]=y-b,n[o+10]=1-(l+g),n[o+11]=0,n[o+12]=t.x(),n[o+13]=t.y(),n[o+14]=t.z(),n[o+15]=1}export{t as AmmoPhysics};
@@ -1 +0,0 @@
1
- export * from "three/examples/jsm/physics/AmmoPhysics.js";