lecodes-sdk 0.20.2 → 1.1.0
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/global.d.ts +35 -9
- package/dist/types/animate/tween/Animation.d.ts +69 -0
- package/dist/types/animate/tween/Timeline.d.ts +55 -0
- package/dist/types/animate/tween/animateValue.d.ts +27 -0
- package/dist/types/animate/tween/easing.d.ts +29 -0
- package/dist/types/animate/tween/spec.d.ts +178 -0
- package/dist/types/canvas/Canvas.d.ts +2 -0
- package/dist/types/g2/Node2D.d.ts +16 -0
- package/dist/types/g2/Sprite.d.ts +11 -1
- package/dist/types/gl/Camera.d.ts +15 -1
- package/dist/types/gl/DecalSet.d.ts +48 -3
- package/dist/types/gl/Foliage.d.ts +47 -0
- package/dist/types/gl/Geometry.d.ts +36 -0
- package/dist/types/gl/Light.d.ts +25 -7
- package/dist/types/gl/Lightmap.d.ts +90 -51
- package/dist/types/gl/Material.d.ts +32 -20
- package/dist/types/gl/Mesh.d.ts +7 -1
- package/dist/types/gl/Model.d.ts +41 -5
- package/dist/types/gl/Node.d.ts +18 -0
- package/dist/types/gl/Particles.d.ts +53 -1
- package/dist/types/gl/Scene.d.ts +21 -1
- package/dist/types/gl/animation/AnimationClip.d.ts +19 -0
- package/dist/types/gl/animation/Animator.d.ts +27 -0
- package/dist/types/gl/animation/DynamicBone.d.ts +184 -0
- package/dist/types/gl/animation/IK.d.ts +109 -0
- package/dist/types/gl/{Locomotion.d.ts → animation/Locomotion.d.ts} +6 -6
- package/dist/types/gl/animation/Warp.d.ts +2 -1
- package/dist/types/gl/animation/core.d.ts +35 -4
- package/dist/types/gl/{AudioSource.d.ts → audio/AudioSource.d.ts} +6 -6
- package/dist/types/gl/{AudioZone.d.ts → audio/AudioZone.d.ts} +4 -4
- package/dist/types/gl/{SceneAudio.d.ts → audio/SceneAudio.d.ts} +1 -1
- package/dist/types/gl/{NavAgent.d.ts → nav/NavAgent.d.ts} +4 -4
- package/dist/types/gl/{NavMesh.d.ts → nav/NavMesh.d.ts} +4 -4
- package/dist/types/gl/{CharacterController.d.ts → physics/CharacterController.d.ts} +5 -5
- package/dist/types/gl/{Physics.d.ts → physics/Physics.d.ts} +6 -5
- package/dist/types/gl/physics/Ragdoll.d.ts +161 -0
- package/dist/types/gl/{Shape.d.ts → physics/Shape.d.ts} +3 -3
- package/dist/types/gl/{Trigger.d.ts → physics/Trigger.d.ts} +2 -2
- package/dist/types/gl/{Terrain.d.ts → terrain/Terrain.d.ts} +10 -8
- package/dist/types/gl/{terrainMesh.d.ts → terrain/terrainMesh.d.ts} +1 -1
- package/dist/types/gl/vehicle/Vehicle.d.ts +300 -0
- package/dist/types/gl/vehicle/Wheel.d.ts +147 -0
- package/dist/types/inject.d.ts +35 -27
- package/dist/types/runtime/files.d.ts +24 -1
- package/dist/types/scene/defineScene.d.ts +50 -31
- package/dist/types/ui/UIButton.d.ts +3 -1
- package/dist/types/ui/UIInput.d.ts +5 -1
- package/dist/types/ui/UINode.d.ts +24 -24
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/prompts/README.md +142 -142
- package/prompts/core-design.md +27 -4
- package/prompts/core.md +35 -6
- package/prompts/select.ts +19 -4
- package/src/animate/tween/Animation.ts +378 -0
- package/src/animate/tween/Timeline.ts +175 -0
- package/src/animate/tween/animateValue.ts +100 -0
- package/src/animate/tween/easing.ts +172 -0
- package/src/animate/tween/spec.ts +479 -0
- package/src/bridges.d.ts +1760 -1481
- package/src/canvas/Canvas.ts +21 -0
- package/src/compile/__tests__/assetMacro.test.ts +26 -0
- package/src/compile/__tests__/compile.test.ts +11 -0
- package/src/compile/__tests__/detectEntry.test.ts +19 -0
- package/src/compile/__tests__/serverSplit.test.ts +27 -0
- package/src/compile/bundler.ts +34 -4
- package/src/compile/compileProject.ts +31 -1
- package/src/compile/detectEntry.ts +8 -3
- package/src/compile/header.ts +6 -3
- package/src/compile/index.ts +3 -0
- package/src/compile/sceneEditor.ts +42 -1
- package/src/compile/serverSplit.ts +9 -3
- package/src/g2/Node2D.ts +38 -0
- package/src/g2/Sprite.ts +20 -1
- package/src/gl/Camera.ts +34 -1
- package/src/gl/DecalSet.ts +132 -5
- package/src/gl/Foliage.ts +102 -0
- package/src/gl/Geometry.ts +109 -0
- package/src/gl/Light.ts +46 -16
- package/src/gl/Lightmap.ts +440 -249
- package/src/gl/Material.ts +69 -36
- package/src/gl/Mesh.ts +120 -102
- package/src/gl/Model.ts +167 -124
- package/src/gl/Node.ts +40 -1
- package/src/gl/Particles.ts +82 -5
- package/src/gl/Scene.ts +35 -2
- package/src/gl/animation/AnimationClip.ts +52 -0
- package/src/gl/animation/Animator.ts +42 -2
- package/src/gl/animation/DynamicBone.ts +482 -0
- package/src/gl/animation/IK.ts +214 -0
- package/src/gl/{Locomotion.ts → animation/Locomotion.ts} +7 -7
- package/src/gl/animation/Playback.ts +5 -4
- package/src/gl/animation/Warp.ts +5 -2
- package/src/gl/animation/core.ts +65 -4
- package/src/gl/{AudioSource.ts → audio/AudioSource.ts} +7 -7
- package/src/gl/{AudioZone.ts → audio/AudioZone.ts} +75 -75
- package/src/gl/{SceneAudio.ts → audio/SceneAudio.ts} +2 -2
- package/src/gl/{NavAgent.ts → nav/NavAgent.ts} +5 -5
- package/src/gl/{NavMesh.ts → nav/NavMesh.ts} +8 -8
- package/src/gl/{CharacterController.ts → physics/CharacterController.ts} +5 -5
- package/src/gl/{Physics.ts → physics/Physics.ts} +12 -5
- package/src/gl/physics/Ragdoll.ts +451 -0
- package/src/gl/{Shape.ts → physics/Shape.ts} +3 -3
- package/src/gl/{Trigger.ts → physics/Trigger.ts} +45 -45
- package/src/gl/{physicsEvents.ts → physics/physicsEvents.ts} +1 -1
- package/src/gl/{Terrain.ts → terrain/Terrain.ts} +14 -12
- package/src/gl/{terrainMesh.ts → terrain/terrainMesh.ts} +1 -1
- package/src/gl/vehicle/Vehicle.ts +666 -0
- package/src/gl/vehicle/Wheel.ts +290 -0
- package/src/inject.ts +236 -224
- package/src/runtime/files.ts +32 -2
- package/src/scene/defineScene.ts +92 -66
- package/src/scene/level.ts +2 -2
- package/src/ui/UIButton.ts +2 -2
- package/src/ui/UIInput.ts +3 -3
- package/src/ui/UINode.ts +61 -36
- package/dist/types/animate/animate.d.ts +0 -20
- package/dist/types/gl/Gearbox.d.ts +0 -86
- package/dist/types/gl/IK.d.ts +0 -53
- package/dist/types/gl/Ragdoll.d.ts +0 -86
- package/dist/types/gl/Vehicle.d.ts +0 -191
- package/dist/types/gl/Wheel.d.ts +0 -95
- package/src/animate/animate.ts +0 -238
- package/src/gl/Gearbox.ts +0 -212
- package/src/gl/IK.ts +0 -193
- package/src/gl/Ragdoll.ts +0 -270
- package/src/gl/Vehicle.ts +0 -473
- package/src/gl/Wheel.ts +0 -240
- /package/dist/types/gl/{physicsEvents.d.ts → physics/physicsEvents.d.ts} +0 -0
package/src/gl/Wheel.ts
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
// One wheel of a `Vehicle`, as an aspect on the wheel's own node. The node's position IS the wheel's
|
|
2
|
-
// position (where its centre rests on flat ground), and everything else about it lives here too:
|
|
3
|
-
//
|
|
4
|
-
// const car = new Node('car')
|
|
5
|
-
// .add(body, wheelFL.aspect(Wheel), wheelFR.aspect(Wheel),
|
|
6
|
-
// wheelRL.aspect(Wheel), wheelRR.aspect(Wheel))
|
|
7
|
-
// .aspect(Shape, { box: [0.9, 0.4, 2.1] })
|
|
8
|
-
// .aspect(Vehicle, { mass: 1200 })
|
|
9
|
-
//
|
|
10
|
-
// That is the whole minimum: `Vehicle` collects every `Wheel` under itself, groups them into axles by
|
|
11
|
-
// Z (front first), and the defaults fall out — the front axle steers, the rear one drives and carries
|
|
12
|
-
// the handbrake. Override any of it per wheel.
|
|
13
|
-
//
|
|
14
|
-
// This aspect is also what POSES the wheel: it runs in the LATE phase (after the physics step, before
|
|
15
|
-
// the frame draws) and writes the node's transform from the suspension length, steer angle and spin
|
|
16
|
-
// the engine reports. Nothing else writes that transform — the engine deliberately does not, so a
|
|
17
|
-
// wheel model's own conventions (which way its axle points, how big it looks) are settings here
|
|
18
|
-
// rather than constants in C++, and a part that should steer but NOT spin is simply a sibling node.
|
|
19
|
-
//
|
|
20
|
-
// Chassis space is forward −Z / up +Y, the SDK's own convention (`node.forward`).
|
|
21
|
-
|
|
22
|
-
import { Aspect } from "../core/Aspect"
|
|
23
|
-
import type { FieldMeta } from "../core/fields"
|
|
24
|
-
import { Mat4 } from "../math/mat4"
|
|
25
|
-
import { Quat } from "../math/quat"
|
|
26
|
-
import { Vec3, cx, cy, cz, type Vec3Like } from "../math/vec"
|
|
27
|
-
import { Gizmos } from "../scene/gizmos"
|
|
28
|
-
import { Node } from "./Node"
|
|
29
|
-
import { Shape } from "./Shape"
|
|
30
|
-
import type { Vehicle } from "./Vehicle"
|
|
31
|
-
|
|
32
|
-
/** Floats `vehicleGetState` writes before the per-wheel block: speed, rpm, contacts, vx, vy, vz. */
|
|
33
|
-
export const STATE_HEADER = 6
|
|
34
|
-
/** Floats per wheel: contact, slip, slipAngle, suspensionLength, steerDeg, spin. */
|
|
35
|
-
export const WHEEL_STATE = 6
|
|
36
|
-
|
|
37
|
-
/** How a tire behaves past its grip peak. `road` is Jolt's own curve — grip falls off after the peak,
|
|
38
|
-
* so the car can be made to let go. `arcade` holds the peak all the way out: much harder to spin. */
|
|
39
|
-
export type TireCurve = "road" | "arcade"
|
|
40
|
-
|
|
41
|
-
export interface WheelSuspension {
|
|
42
|
-
/** Total travel in metres, full droop to fully compressed (default 0.4). */
|
|
43
|
-
travel?: number
|
|
44
|
-
/** Spring frequency in Hz — bigger is stiffer (default 1.4; a race car ~2.5, a truck ~1). It also
|
|
45
|
-
* sets the ride-height sag, and the sag is how far the wheel can still extend DOWN. */
|
|
46
|
-
stiffness?: number
|
|
47
|
-
/** Damping ratio 0..1 (default 0.5). Low values pogo. */
|
|
48
|
-
damping?: number
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface WheelTire {
|
|
52
|
-
/** Grip multiplier on the friction curves (default 1). The grip a wheel actually gets is combined
|
|
53
|
-
* with the ground it stands on as `sqrt(tire × groundFriction)`, and a body's friction defaults to
|
|
54
|
-
* 0.6 — so a road a car should really corner on wants `Physics { friction: 1 }`. */
|
|
55
|
-
grip?: number
|
|
56
|
-
/** Which friction curve (default `road`). */
|
|
57
|
-
curve?: TireCurve
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface WheelVisual {
|
|
61
|
-
/** The MODEL's axle direction in its own space (default `[1, 0, 0]`). Set it instead of parenting
|
|
62
|
-
* the mesh under a corrective node when the art points another way. */
|
|
63
|
-
axis?: Vec3Like
|
|
64
|
-
/** Drawn radius, if the art is not exactly the physical `radius` — sinks a wheel into its arch or
|
|
65
|
-
* lets a fat tire overhang, with no effect on the simulation. Default: the physical radius. */
|
|
66
|
-
radius?: number
|
|
67
|
-
/** Let the model spin (default true). `false` keeps the steer angle and suspension travel but not
|
|
68
|
-
* the rotation — a brake caliper. */
|
|
69
|
-
spin?: boolean
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const DEG2RAD = Math.PI / 180
|
|
73
|
-
const UP = new Vec3(0, 1, 0)
|
|
74
|
-
|
|
75
|
-
export class Wheel extends Aspect<"wheel", Node> {
|
|
76
|
-
static readonly aspect = "wheel"
|
|
77
|
-
|
|
78
|
-
/** Wheel radius in metres. Default: measured from the node's rendered bounds, else 0.35. Too small
|
|
79
|
-
* and the car scrapes, too large and it floats. */
|
|
80
|
-
radius?: number
|
|
81
|
-
/** Wheel width in metres. Default: measured, else 0.25. */
|
|
82
|
-
width?: number
|
|
83
|
-
/** Does this wheel steer? Default: the wheels on the front axle. */
|
|
84
|
-
steer?: boolean
|
|
85
|
-
/** Does the engine drive it? Default: from the vehicle's `drive` layout. */
|
|
86
|
-
drive?: boolean
|
|
87
|
-
/** Foot brake on this wheel. */
|
|
88
|
-
brake = true
|
|
89
|
-
/** Handbrake on this wheel. Default: every non-steering wheel (locking the front wheels of a moving
|
|
90
|
-
* car is not a handbrake turn, it is a crash). */
|
|
91
|
-
handbrake?: boolean
|
|
92
|
-
/** Axle group, front to back. Default: derived from Z. Set it for a car whose wheels are not in neat
|
|
93
|
-
* left/right pairs — an axle's wheels are paired for the differential and the anti-roll bar. */
|
|
94
|
-
axle?: number
|
|
95
|
-
/** Foot-brake torque in N·m (default 1500); the handbrake pulls 3× on the wheels that have it. */
|
|
96
|
-
brakeTorque = 1500
|
|
97
|
-
|
|
98
|
-
suspension: WheelSuspension = { travel: 0.4, stiffness: 1.4, damping: 0.5 }
|
|
99
|
-
tire: WheelTire = { grip: 1, curve: "road" }
|
|
100
|
-
visual: WheelVisual = {}
|
|
101
|
-
|
|
102
|
-
/** Scene-editor inspector. `steer` / `drive` / `handbrake` are deliberately absent: they are
|
|
103
|
-
* tri-state (undefined = derive it from the axle), which a switch cannot express. */
|
|
104
|
-
static fields: FieldMeta<Wheel> = {
|
|
105
|
-
radius: { min: 0.05, step: 0.01 },
|
|
106
|
-
width: { min: 0.02, step: 0.01 },
|
|
107
|
-
axle: { min: 0, step: 1 },
|
|
108
|
-
brake: { label: "Foot brake" },
|
|
109
|
-
brakeTorque: { label: "Brake torque", min: 0, step: 50 },
|
|
110
|
-
suspension: { hidden: true },
|
|
111
|
-
tire: { hidden: true },
|
|
112
|
-
visual: { hidden: true },
|
|
113
|
-
}
|
|
114
|
-
static editor = { rebuild: true }
|
|
115
|
-
|
|
116
|
-
/** @internal Set by `Vehicle` at attach — the car this wheel belongs to, and its index in the blob. */
|
|
117
|
-
_vehicle: Vehicle | null = null
|
|
118
|
-
/** @internal */
|
|
119
|
-
_index = -1
|
|
120
|
-
/** @internal Suspension attachment point in chassis space; the wheel hangs below it. */
|
|
121
|
-
_attach = new Vec3()
|
|
122
|
-
/** @internal Resting centre in chassis space (what the author placed). */
|
|
123
|
-
_rest = new Vec3()
|
|
124
|
-
|
|
125
|
-
private _angle = 0 // integrated spin, radians — the engine reports rate, not angle
|
|
126
|
-
private _scale = new Vec3(1, 1, 1) // the node's own scale, preserved through the pose write
|
|
127
|
-
private _local = true // is the node a direct child of the chassis?
|
|
128
|
-
|
|
129
|
-
onAttach(): void {
|
|
130
|
-
this._scale = this.node.scale
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
onDetach(): void {
|
|
134
|
-
this._vehicle = null
|
|
135
|
-
this._index = -1
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** @internal Called by Vehicle once the car exists, with the geometry it resolved. */
|
|
139
|
-
_bind(vehicle: Vehicle, index: number, rest: Vec3, attach: Vec3): void {
|
|
140
|
-
this._vehicle = vehicle
|
|
141
|
-
this._index = index
|
|
142
|
-
this._rest = rest
|
|
143
|
-
this._attach = attach
|
|
144
|
-
this._scale = this.node.scale
|
|
145
|
-
this._local = this.node.parent === vehicle.node
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ---- live state ------------------------------------------------------------------------------
|
|
149
|
-
// Every getter reads the car's ONE shared state buffer, which is refreshed once per frame.
|
|
150
|
-
|
|
151
|
-
private _state(k: number): number {
|
|
152
|
-
const v = this._vehicle
|
|
153
|
-
if (!v || this._index < 0) return 0
|
|
154
|
-
return v._wheelState(this._index, k)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Touching the ground this step. */
|
|
158
|
-
get contact(): boolean { return this._state(0) !== 0 }
|
|
159
|
-
/** Longitudinal slip RATIO: 0 = rolling in sync with the ground, ~1 = spinning up or locked.
|
|
160
|
-
* Unsigned — smoke, tire marks and wheelspin sound key off this. */
|
|
161
|
-
get slip(): number { return this._state(1) }
|
|
162
|
-
/** Slip ANGLE in degrees: how far the tire's travel direction is off from where it points.
|
|
163
|
-
* Unsigned, 0..90 — past the curve's peak (~3°) the tire is sliding sideways. Drift particles. */
|
|
164
|
-
get slipAngle(): number { return this._state(2) }
|
|
165
|
-
/** Steer angle in degrees, positive to the right. */
|
|
166
|
-
get steerAngle(): number { return this._state(4) }
|
|
167
|
-
/** Wheel spin in rad/s (× radius ≈ the speed the tire is laying down). */
|
|
168
|
-
get spin(): number { return this._state(5) }
|
|
169
|
-
/** Suspension compression, 0 = fully extended (drooping) … 1 = fully compressed. */
|
|
170
|
-
get compression(): number {
|
|
171
|
-
const travel = this.suspension.travel ?? 0.4
|
|
172
|
-
if (travel <= 0) return 0
|
|
173
|
-
const len = this._state(3)
|
|
174
|
-
const min = travel * 0.4
|
|
175
|
-
return Math.max(0, Math.min(1, (travel - len) / (travel - min)))
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ---- the visual ------------------------------------------------------------------------------
|
|
179
|
-
|
|
180
|
-
/** LATE phase: after the step and the transform sync, right before the frame draws. */
|
|
181
|
-
update(dt: number): void {
|
|
182
|
-
const v = this._vehicle
|
|
183
|
-
if (!v || this._index < 0 || !v.id) return
|
|
184
|
-
|
|
185
|
-
if (this.visual.spin !== false) this._angle += this._state(5) * dt
|
|
186
|
-
|
|
187
|
-
// Down the suspension from the attachment point by however far it currently hangs.
|
|
188
|
-
const length = this._state(3)
|
|
189
|
-
const centre = new Vec3(this._attach.x, this._attach.y - length, this._attach.z)
|
|
190
|
-
|
|
191
|
-
// Steer about the chassis' up axis, then spin about the MODEL's own axle in the steered frame.
|
|
192
|
-
// Both reports are negated, for the same reason: the engine describes them in the DRIVER's terms
|
|
193
|
-
// and the scene is right-handed with forward on −Z. Steer is reported right-positive while a yaw
|
|
194
|
-
// about +Y turns left. Spin is reported positive-means-forward, but a positive turn about the
|
|
195
|
-
// right-hand axle carries the top of the wheel to +Z — which rolls the car backwards.
|
|
196
|
-
const steer = Quat.fromAxisAngle(UP, -this._state(4) * DEG2RAD)
|
|
197
|
-
const axis = this.visual.axis ?? [1, 0, 0]
|
|
198
|
-
const rotation = this.visual.spin === false ? steer : steer.mul(Quat.fromAxisAngle(axis, -this._angle))
|
|
199
|
-
|
|
200
|
-
// A model that draws bigger or smaller than it collides scales on top of the node's own scale.
|
|
201
|
-
const vr = this.visual.radius
|
|
202
|
-
const k = vr !== undefined && this.radius ? vr / this.radius : 1
|
|
203
|
-
const scale = k === 1 ? this._scale : new Vec3(this._scale.x * k, this._scale.y * k, this._scale.z * k)
|
|
204
|
-
|
|
205
|
-
const m = Mat4.compose(centre, rotation, scale)
|
|
206
|
-
// The common case is a direct child of the chassis, where chassis space IS the local space.
|
|
207
|
-
if (this._local) this.node.matrix = m
|
|
208
|
-
else this.node.worldMatrix = new Mat4(v.node.worldMatrix).mul(m)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** Edit mode: this wheel's own circle at its resting height, its travel range, and a mark when the
|
|
212
|
-
* engine drives it — enough to place a wheel without running the game. */
|
|
213
|
-
rebuild(): void {
|
|
214
|
-
const travel = this.suspension.travel ?? 0.4
|
|
215
|
-
const r = this.radius ?? this._measure().radius
|
|
216
|
-
const world = new Mat4(this.node.worldMatrix)
|
|
217
|
-
const P = (x: number, y: number, z: number): Vec3 => world.transformPoint([ x, y, z ])
|
|
218
|
-
const ring: Vec3[] = []
|
|
219
|
-
for (let i = 0; i < 24; i++) {
|
|
220
|
-
const t = (i / 24) * Math.PI * 2
|
|
221
|
-
ring.push(P(0, Math.sin(t) * r, Math.cos(t) * r))
|
|
222
|
-
}
|
|
223
|
-
Gizmos.polyline(ring, { color: this.steer === false ? "#9aa3b2" : "#5b8ef0", closed: true })
|
|
224
|
-
Gizmos.line(P(0, travel * 0.6, 0), P(0, -travel * 0.4, 0), { color: "#59606d" })
|
|
225
|
-
if (this.drive) Gizmos.cross(P(0, 0, 0), r * 0.35, { color: "#e0b25a" })
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** @internal Radius/width from the node's rendered bounds, so a placed model needs no numbers. */
|
|
229
|
-
_measure(): { radius: number, width: number } {
|
|
230
|
-
const b = Shape.boundsOf(this.node)
|
|
231
|
-
if (!b) return { radius: 0.35, width: 0.25 }
|
|
232
|
-
const size = new Vec3(cx(b.max) - cx(b.min), cy(b.max) - cy(b.min), cz(b.max) - cz(b.min))
|
|
233
|
-
// A wheel is a disc: its diameter is the larger of the two axes across the axle, and the width is
|
|
234
|
-
// the axle direction itself.
|
|
235
|
-
const axis = this.visual.axis ?? [1, 0, 0]
|
|
236
|
-
const along = Math.abs(cx(axis)) >= Math.abs(cz(axis)) ? size.x : size.z
|
|
237
|
-
const across = Math.max(Math.abs(cx(axis)) >= Math.abs(cz(axis)) ? size.z : size.x, size.y)
|
|
238
|
-
return { radius: across > 0 ? across * 0.5 : 0.35, width: along > 0 ? along : 0.25 }
|
|
239
|
-
}
|
|
240
|
-
}
|
|
File without changes
|