@threlte/rapier 0.5.0 → 1.0.0-next.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.
- package/dist/CHANGELOG.md +12 -0
- package/dist/components/Attractor/Attractor.svelte +17 -13
- package/dist/components/Attractor/Attractor.svelte.d.ts +20 -22
- package/dist/components/Colliders/AutoColliders.svelte +52 -50
- package/dist/components/Colliders/AutoColliders.svelte.d.ts +80 -0
- package/dist/components/Colliders/Collider.svelte +40 -30
- package/dist/components/Colliders/Collider.svelte.d.ts +110 -112
- package/dist/components/CollisionGroups/CollisionGroups.svelte +1 -20
- package/dist/components/CollisionGroups/CollisionGroups.svelte.d.ts +29 -19
- package/dist/components/Debug/Debug.svelte +13 -10
- package/dist/components/Debug/Debug.svelte.d.ts +6 -60
- package/dist/components/RigidBody/RigidBody.svelte +23 -58
- package/dist/components/RigidBody/RigidBody.svelte.d.ts +94 -67
- package/dist/components/World/InnerWorld.svelte +11 -7
- package/dist/components/World/InnerWorld.svelte.d.ts +15 -15
- package/dist/components/World/World.svelte +13 -2
- package/dist/components/World/World.svelte.d.ts +36 -32
- package/dist/hooks/useFixedJoint.d.ts +2 -2
- package/dist/hooks/useFixedJoint.js +6 -3
- package/dist/hooks/useFrameHandler.d.ts +1 -1
- package/dist/hooks/useFrameHandler.js +9 -8
- package/dist/hooks/usePrismaticJoint.d.ts +2 -2
- package/dist/hooks/usePrismaticJoint.js +5 -2
- package/dist/hooks/useRevoluteJoint.d.ts +2 -2
- package/dist/hooks/useRevoluteJoint.js +5 -2
- package/dist/hooks/useSphericalJoint.d.ts +2 -2
- package/dist/hooks/useSphericalJoint.js +4 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/lib/applyTransforms.d.ts +2 -3
- package/dist/lib/applyTransforms.js +7 -16
- package/dist/lib/computeBitMask.d.ts +5 -0
- package/dist/lib/computeBitMask.js +20 -0
- package/dist/lib/createRapierContext.d.ts +3 -0
- package/dist/lib/createRapierContext.js +10 -1
- package/dist/lib/eulerToQuaternion.d.ts +7 -0
- package/dist/lib/eulerToQuaternion.js +12 -0
- package/dist/lib/scaleColliderArgs.js +3 -3
- package/dist/recipes/BasicPlayerController.svelte +28 -27
- package/dist/recipes/BasicPlayerController.svelte.d.ts +2 -5
- package/dist/types/components.d.ts +1 -88
- package/dist/types/types.d.ts +5 -5
- package/package.json +10 -9
- package/dist/components/Joints/RevoluteJoint.svelte +0 -5
- package/dist/components/Joints/RevoluteJoint.svelte.d.ts +0 -23
- package/dist/lib/positionToVector3.d.ts +0 -3
- package/dist/lib/positionToVector3.js +0 -8
- package/dist/lib/rotationToEuler.d.ts +0 -3
- package/dist/lib/rotationToEuler.js +0 -8
- package/dist/lib/rotationToQuaternion.d.ts +0 -3
- package/dist/lib/rotationToQuaternion.js +0 -10
- package/dist/lib/scaleToVector3.d.ts +0 -3
- package/dist/lib/scaleToVector3.js +0 -16
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Quaternion } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the values of a temporary Euler and returns the quaternion from that
|
|
4
|
+
* @param values
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare const eulerToQuaternion: (values: [x: number, y: number, z: number, order?: string | undefined]) => Quaternion;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Euler, Quaternion } from 'three';
|
|
2
|
+
const e = new Euler();
|
|
3
|
+
const q = new Quaternion();
|
|
4
|
+
/**
|
|
5
|
+
* Sets the values of a temporary Euler and returns the quaternion from that
|
|
6
|
+
* @param values
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export const eulerToQuaternion = (values) => {
|
|
10
|
+
e.set(...values);
|
|
11
|
+
return q.setFromEuler(e);
|
|
12
|
+
};
|
|
@@ -11,8 +11,8 @@ export const scaleColliderArgs = (shape, args, scale) => {
|
|
|
11
11
|
// Heightfield only scales the last arg
|
|
12
12
|
const newArgs = args.slice();
|
|
13
13
|
if (shape === 'heightfield') {
|
|
14
|
-
|
|
15
|
-
newArgs[3]
|
|
14
|
+
// Is this for auto scaling heightfield to THREE scale of the object?
|
|
15
|
+
// ;(newArgs[3] as number) = scale.x
|
|
16
16
|
return newArgs;
|
|
17
17
|
}
|
|
18
18
|
// Trimesh and convex scale the vertices
|
|
@@ -21,5 +21,5 @@ export const scaleColliderArgs = (shape, args, scale) => {
|
|
|
21
21
|
return newArgs;
|
|
22
22
|
}
|
|
23
23
|
const scaleArray = [scale.x, scale.y, scale.z];
|
|
24
|
-
return newArgs.map((arg, index) => scaleArray[index] * arg);
|
|
24
|
+
return newArgs.map((arg, index) => (scaleArray[index] ?? 1) * arg);
|
|
25
25
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
1
|
+
<script>import { createRawEventDispatcher, T, useFrame, useThrelte } from '@threlte/core';
|
|
3
2
|
import { Vector2, Vector3 } from 'three';
|
|
4
3
|
import Collider from '../components/Colliders/Collider.svelte';
|
|
5
4
|
import CollisionGroups from '../components/CollisionGroups/CollisionGroups.svelte';
|
|
@@ -23,7 +22,7 @@ const keys = {
|
|
|
23
22
|
};
|
|
24
23
|
const t = new Vector3();
|
|
25
24
|
const t2 = new Vector2();
|
|
26
|
-
const dispatch =
|
|
25
|
+
const dispatch = createRawEventDispatcher();
|
|
27
26
|
let grounded = false;
|
|
28
27
|
let groundsSensored = 0;
|
|
29
28
|
$: {
|
|
@@ -101,29 +100,31 @@ const onKeyUp = (e) => {
|
|
|
101
100
|
|
|
102
101
|
<svelte:window on:keydown|preventDefault={onKeyDown} on:keyup|preventDefault={onKeyUp} />
|
|
103
102
|
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
<T.Group {position}>
|
|
104
|
+
<RigidBody
|
|
105
|
+
dominance={127}
|
|
106
|
+
enabledRotations={[false, false, false]}
|
|
107
|
+
bind:rigidBody
|
|
108
|
+
type={'dynamic'}
|
|
109
|
+
>
|
|
110
|
+
<CollisionGroups groups={playerCollisionGroups}>
|
|
111
|
+
<Collider shape={'capsule'} args={[height / 2 - radius, radius]} />
|
|
112
|
+
</CollisionGroups>
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
<CollisionGroups groups={groundCollisionGroups}>
|
|
115
|
+
<T.Group position={[0, -height / 2 + radius, 0]}>
|
|
116
|
+
<Collider
|
|
117
|
+
sensor
|
|
118
|
+
on:sensorenter={() => (groundsSensored += 1)}
|
|
119
|
+
on:sensorexit={() => (groundsSensored -= 1)}
|
|
120
|
+
shape={'ball'}
|
|
121
|
+
args={[radius * 1.2]}
|
|
122
|
+
/>
|
|
123
|
+
</T.Group>
|
|
124
|
+
</CollisionGroups>
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
</RigidBody>
|
|
126
|
+
<T.Group position.y={-height / 2}>
|
|
127
|
+
<slot />
|
|
128
|
+
</T.Group>
|
|
129
|
+
</RigidBody>
|
|
130
|
+
</T.Group>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
3
|
import type { CollisionGroupsBitMask } from '../types/types';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
|
-
position?:
|
|
6
|
+
position?: Parameters<Vector3['set']> | undefined;
|
|
7
7
|
height?: number | undefined;
|
|
8
8
|
radius?: number | undefined;
|
|
9
9
|
speed?: number | undefined;
|
|
@@ -12,9 +12,6 @@ declare const __propDef: {
|
|
|
12
12
|
groundCollisionGroups?: CollisionGroupsBitMask | undefined;
|
|
13
13
|
};
|
|
14
14
|
events: {
|
|
15
|
-
groundenter: CustomEvent<void>;
|
|
16
|
-
groundexit: CustomEvent<void>;
|
|
17
|
-
} & {
|
|
18
15
|
[evt: string]: CustomEvent<any>;
|
|
19
16
|
};
|
|
20
17
|
slots: {
|
|
@@ -1,78 +1,8 @@
|
|
|
1
1
|
import type { CoefficientCombineRule, ColliderDesc } from '@dimforge/rapier3d-compat';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Position, Rotation, TransformableObjectProperties } from '@threlte/core';
|
|
4
|
-
import type { RigidBodyTypeString } from '../lib/parseRigidBodyType';
|
|
2
|
+
import type { Position, TransformableObjectProperties } from '@threlte/core';
|
|
5
3
|
import type { AutoCollidersShapes, ColliderShapes, CollisionGroupsBitMask } from './types';
|
|
6
|
-
export declare type Boolean3Array = [x: boolean, y: boolean, z: boolean];
|
|
7
4
|
export declare type Vector3Array = [x: number, y: number, z: number];
|
|
8
5
|
export declare type GravityType = 'static' | 'linear' | 'newtonian';
|
|
9
|
-
export declare type RigidBodyProperties = Omit<TransformableObjectProperties, 'object'> & {
|
|
10
|
-
/**
|
|
11
|
-
* Specify the type of this rigid body
|
|
12
|
-
*/
|
|
13
|
-
type?: RigidBodyTypeString;
|
|
14
|
-
/** Whether or not this body can sleep.
|
|
15
|
-
* default: true
|
|
16
|
-
*/
|
|
17
|
-
canSleep?: boolean;
|
|
18
|
-
/** The linear velocity of this body.
|
|
19
|
-
* default: zero velocity
|
|
20
|
-
*/
|
|
21
|
-
linearVelocity?: Position;
|
|
22
|
-
/** The angular velocity of this body.
|
|
23
|
-
* Default: zero velocity.
|
|
24
|
-
*/
|
|
25
|
-
angularVelocity?: Rotation;
|
|
26
|
-
/**
|
|
27
|
-
* The scaling factor applied to the gravity affecting the rigid-body.
|
|
28
|
-
* Default: 1.0
|
|
29
|
-
*/
|
|
30
|
-
gravityScale?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Whether or not Continous Collision Detection is enabled for this rigid-body.
|
|
33
|
-
* https://rapier.rs/docs/user_guides/javascript/rigid_bodies#continuous-collision-detection
|
|
34
|
-
* @default false
|
|
35
|
-
*/
|
|
36
|
-
ccd?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Locks all rotations that would have resulted from forces on the created rigid-body.
|
|
39
|
-
*/
|
|
40
|
-
lockRotations?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Locks all translations that would have resulted from forces on the created rigid-body.
|
|
43
|
-
*/
|
|
44
|
-
lockTranslations?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Allow rotation of this rigid-body only along specific axes.
|
|
47
|
-
*/
|
|
48
|
-
enabledRotations?: Boolean3Array;
|
|
49
|
-
/**
|
|
50
|
-
* Allow rotation of this rigid-body only along specific axes.
|
|
51
|
-
*/
|
|
52
|
-
enabledTranslations?: Boolean3Array;
|
|
53
|
-
/**
|
|
54
|
-
* Dominance is a non-realistic, but sometimes useful, feature.
|
|
55
|
-
* It can be used to make one rigid-body immune to forces
|
|
56
|
-
* originating from contacts with some other bodies.
|
|
57
|
-
*
|
|
58
|
-
* Number in the range -127 to 127, default is 0
|
|
59
|
-
*/
|
|
60
|
-
dominance?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Damping lets you slow down a rigid-body automatically. This can be used to
|
|
63
|
-
* achieve a wide variety of effects like fake air friction. Larger values of
|
|
64
|
-
* damping coefficients lead to a stronger slow-downs. Their default
|
|
65
|
-
* values are 0.0 (no damping at all).
|
|
66
|
-
*/
|
|
67
|
-
linearDamping?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Damping lets you slow down a rigid-body automatically. This can be used to
|
|
70
|
-
* achieve a wide variety of effects like fake air friction. Larger values of
|
|
71
|
-
* damping coefficients lead to a stronger slow-downs. Their default
|
|
72
|
-
* values are 0.0 (no damping at all).
|
|
73
|
-
*/
|
|
74
|
-
angularDamping?: number;
|
|
75
|
-
};
|
|
76
6
|
export declare type ColliderProperties<Shape extends ColliderShapes> = Omit<TransformableObjectProperties, 'object'> & {
|
|
77
7
|
shape: Shape;
|
|
78
8
|
/**
|
|
@@ -122,23 +52,6 @@ export declare type ColliderProperties<Shape extends ColliderShapes> = Omit<Tran
|
|
|
122
52
|
sensor?: boolean;
|
|
123
53
|
};
|
|
124
54
|
export declare type AutoCollidersProperties = Omit<ColliderProperties<AutoCollidersShapes>, 'args'>;
|
|
125
|
-
export declare type InnerWorldProperties = {
|
|
126
|
-
gravity?: Position;
|
|
127
|
-
rawIntegrationParameters?: RawIntegrationParameters;
|
|
128
|
-
rawIslands?: RawIslandManager;
|
|
129
|
-
rawBroadPhase?: RawBroadPhase;
|
|
130
|
-
rawNarrowPhase?: RawNarrowPhase;
|
|
131
|
-
rawBodies?: RawRigidBodySet;
|
|
132
|
-
rawColliders?: RawColliderSet;
|
|
133
|
-
rawImpulseJoints?: RawImpulseJointSet;
|
|
134
|
-
rawMultibodyJoints?: RawMultibodyJointSet;
|
|
135
|
-
rawCCDSolver?: RawCCDSolver;
|
|
136
|
-
rawQueryPipeline?: RawQueryPipeline;
|
|
137
|
-
rawPhysicsPipeline?: RawPhysicsPipeline;
|
|
138
|
-
rawSerializationPipeline?: RawSerializationPipeline;
|
|
139
|
-
rawDebugRenderPipeline?: RawDebugRenderPipeline;
|
|
140
|
-
};
|
|
141
|
-
export declare type WorldProperties = InnerWorldProperties;
|
|
142
55
|
export declare type CollisionGroupsProperties = {
|
|
143
56
|
groups: CollisionGroupsBitMask;
|
|
144
57
|
} | {
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { createRapierContext } from '../lib/createRapierContext';
|
|
1
|
+
import type { Collider, ColliderHandle, RigidBody, RigidBodyHandle, TempContactManifold, Vector } from '@dimforge/rapier3d-compat';
|
|
2
|
+
import type { createRawEventDispatcher } from '@threlte/core';
|
|
4
3
|
import type { Writable } from 'svelte/store';
|
|
5
4
|
import type { useHasEventListeners } from '../hooks/useHasEventListener';
|
|
5
|
+
import type { createRapierContext } from '../lib/createRapierContext';
|
|
6
6
|
export declare type ColliderShapes = 'ball' | 'capsule' | 'segment' | 'triangle' | 'roundTriangle' | 'polyline' | 'trimesh' | 'cuboid' | 'roundCuboid' | 'heightfield' | 'cylinder' | 'roundCylinder' | 'cone' | 'roundCone' | 'convexHull' | 'convexMesh' | 'roundConvexHull' | 'roundConvexMesh';
|
|
7
7
|
export declare type AutoCollidersShapes = 'cuboid' | 'ball' | 'trimesh' | 'convexHull' | 'capsule';
|
|
8
8
|
export declare type ColliderEventMap = {
|
|
@@ -42,8 +42,8 @@ export declare type RigidBodyEventMap = ColliderEventMap & {
|
|
|
42
42
|
sleep: void;
|
|
43
43
|
wake: void;
|
|
44
44
|
};
|
|
45
|
-
export declare type RigidBodyEventDispatcher = ReturnType<typeof
|
|
46
|
-
export declare type ColliderEventDispatcher = ReturnType<typeof
|
|
45
|
+
export declare type RigidBodyEventDispatcher = ReturnType<typeof createRawEventDispatcher<RigidBodyEventMap>>;
|
|
46
|
+
export declare type ColliderEventDispatcher = ReturnType<typeof createRawEventDispatcher<ColliderEventMap>>;
|
|
47
47
|
export declare type RigidBodyEventDispatchers = Map<RigidBodyHandle, RigidBodyEventDispatcher>;
|
|
48
48
|
export declare type ColliderEventDispatchers = Map<ColliderHandle, ColliderEventDispatcher>;
|
|
49
49
|
export declare type RapierContext = ReturnType<typeof createRapierContext>;
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/rapier",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-next.1",
|
|
4
4
|
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@dimforge/rapier3d-compat": "^0.
|
|
8
|
-
"@sveltejs/adapter-auto": "next",
|
|
9
|
-
"@sveltejs/adapter-static": "
|
|
10
|
-
"@sveltejs/kit": "next",
|
|
11
|
-
"@threlte/core": "
|
|
7
|
+
"@dimforge/rapier3d-compat": "^0.11.2",
|
|
8
|
+
"@sveltejs/adapter-auto": "1.0.0-next.61",
|
|
9
|
+
"@sveltejs/adapter-static": "1.0.0-next.35",
|
|
10
|
+
"@sveltejs/kit": "1.0.0-next.377",
|
|
11
|
+
"@threlte/core": "6.0.0-next.2",
|
|
12
12
|
"@types/node": "^18.0.3",
|
|
13
|
-
"@types/three": "^0.
|
|
13
|
+
"@types/three": "^0.144.0",
|
|
14
14
|
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
|
15
15
|
"@typescript-eslint/parser": "^4.31.1",
|
|
16
16
|
"@yushijinhun/three-minifier-rollup": "^0.3.1",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"svelte-check": "^2.7.0",
|
|
24
24
|
"svelte-preprocess": "^4.10.5",
|
|
25
25
|
"svelte2tsx": "^0.5.9",
|
|
26
|
-
"three": "^0.
|
|
26
|
+
"three": "^0.151.3",
|
|
27
27
|
"ts-node": "^10.8.2",
|
|
28
28
|
"tsafe": "^0.9.0",
|
|
29
29
|
"tslib": "^2.3.1",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
46
46
|
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
|
47
47
|
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
|
48
|
-
"format": "prettier --write --plugin-search-dir=. ."
|
|
48
|
+
"format": "prettier --write --plugin-search-dir=. .",
|
|
49
|
+
"cleanup": "rm -rf node_modules && rm -rf .svelte-kit"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
joint?: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RevoluteImpulseJoint> | undefined;
|
|
5
|
-
rigidBodyA?: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined> | undefined;
|
|
6
|
-
rigidBodyB?: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined> | undefined;
|
|
7
|
-
};
|
|
8
|
-
events: {
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {
|
|
12
|
-
default: {
|
|
13
|
-
rigidBodyA: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
14
|
-
rigidBodyB: import("svelte/store").Writable<import("@dimforge/rapier3d-compat").RigidBody | undefined>;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export declare type RevoluteJointProps = typeof __propDef.props;
|
|
19
|
-
export declare type RevoluteJointEvents = typeof __propDef.events;
|
|
20
|
-
export declare type RevoluteJointSlots = typeof __propDef.slots;
|
|
21
|
-
export default class RevoluteJoint extends SvelteComponentTyped<RevoluteJointProps, RevoluteJointEvents, RevoluteJointSlots> {
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Euler } from 'three';
|
|
2
|
-
export const rotationToEuler = (rotation, euler) => {
|
|
3
|
-
if (euler) {
|
|
4
|
-
euler.set(rotation?.x ?? 0, rotation?.y ?? 0, rotation?.z ?? 0);
|
|
5
|
-
return euler;
|
|
6
|
-
}
|
|
7
|
-
return new Euler(rotation?.x ?? 0, rotation?.y ?? 0, rotation?.z ?? 0);
|
|
8
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Quaternion } from 'three';
|
|
2
|
-
import { rotationToEuler } from './rotationToEuler';
|
|
3
|
-
export const rotationToQuaternion = (rotation, quaternion) => {
|
|
4
|
-
const euler = rotationToEuler(rotation);
|
|
5
|
-
if (quaternion) {
|
|
6
|
-
quaternion.setFromEuler(euler);
|
|
7
|
-
return quaternion;
|
|
8
|
-
}
|
|
9
|
-
return new Quaternion().setFromEuler(euler);
|
|
10
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from 'three';
|
|
2
|
-
export const scaleToVector3 = (scale, v3) => {
|
|
3
|
-
if (v3) {
|
|
4
|
-
if (typeof scale === 'number') {
|
|
5
|
-
v3.set(scale, scale, scale);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
v3.set(scale?.x ?? 1, scale?.y ?? 1, scale?.z ?? 1);
|
|
9
|
-
}
|
|
10
|
-
return v3;
|
|
11
|
-
}
|
|
12
|
-
if (typeof scale === 'number') {
|
|
13
|
-
return new Vector3(scale, scale, scale);
|
|
14
|
-
}
|
|
15
|
-
return new Vector3(scale?.x ?? 1, scale?.y ?? 1, scale?.z ?? 1);
|
|
16
|
-
};
|