@particle-academy/fancy-3d 0.1.6 → 0.3.3
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/README.md +64 -7
- package/dist/babylon.cjs +86 -0
- package/dist/babylon.cjs.map +1 -1
- package/dist/babylon.d.cts +93 -2
- package/dist/babylon.d.ts +93 -2
- package/dist/babylon.js +83 -3
- package/dist/babylon.js.map +1 -1
- package/dist/canvas/index.cjs +802 -0
- package/dist/canvas/index.cjs.map +1 -0
- package/dist/canvas/index.d.cts +205 -0
- package/dist/canvas/index.d.ts +205 -0
- package/dist/canvas/index.js +4 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-USH43TOO.js +791 -0
- package/dist/chunk-USH43TOO.js.map +1 -0
- package/dist/dom.d.cts +1 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +1 -1
- package/dist/index.cjs +798 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -188
- package/dist/index.d.ts +4 -188
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +2 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +3 -3
- package/dist/react.js.map +1 -1
- package/dist/scene-ChcFkvmm.d.cts +188 -0
- package/dist/scene-ChcFkvmm.d.ts +188 -0
- package/docs/Canvas.md +154 -0
- package/package.json +11 -1
package/dist/babylon.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scene, Mesh, Vector3, DynamicTexture } from '@babylonjs/core';
|
|
2
|
-
import { WidgetSpec,
|
|
2
|
+
import { j as WidgetSpec, f as SceneNode, W as WidgetAdapter, S as Scene$1 } from './scene-ChcFkvmm.cjs';
|
|
3
3
|
|
|
4
4
|
declare const TEX_SCALE = 2;
|
|
5
5
|
declare function paintWidget(ctx: CanvasRenderingContext2D, spec: WidgetSpec, w: number, h: number, selected: boolean): void;
|
|
@@ -188,6 +188,97 @@ interface DecalOpts {
|
|
|
188
188
|
declare function createDecal(opts: DecalOpts): Mesh;
|
|
189
189
|
declare function createWidgetTexture(scene: Scene, name: string, widget: WidgetSpec, pixelWidth: number, pixelHeight: number, selected?: boolean): DynamicTexture;
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Layout helpers — map 2D scene-node positions onto 3D arrangements.
|
|
193
|
+
*
|
|
194
|
+
* All layout functions take the same shape: a SceneNode, the Mesh that was
|
|
195
|
+
* built for it, the scene's bounds, and layout-specific options. They mutate
|
|
196
|
+
* `mesh.position` (and sometimes `mesh.rotation`) in place.
|
|
197
|
+
*
|
|
198
|
+
* Pair with `sceneBounds(scene)` from `./babylon` to compute the bounds.
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
interface Bounds {
|
|
202
|
+
minX: number;
|
|
203
|
+
maxX: number;
|
|
204
|
+
minY: number;
|
|
205
|
+
maxY: number;
|
|
206
|
+
}
|
|
207
|
+
interface GridLayoutOpts {
|
|
208
|
+
/** Pixel-to-world unit ratio. Defaults to 1/120. */
|
|
209
|
+
scale?: number;
|
|
210
|
+
/** World-space center of the grid. Defaults to (0, 0, 0). */
|
|
211
|
+
origin?: Vector3;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Direct 2D-to-3D mapping. DOM (x, y) becomes world (x, -y, 0) — the most
|
|
215
|
+
* literal layout. Useful when you want the scene to look identical to its
|
|
216
|
+
* DOM rendering, just rendered as floating panels.
|
|
217
|
+
*/
|
|
218
|
+
declare function placeOnGrid(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: GridLayoutOpts): void;
|
|
219
|
+
interface WallLayoutOpts {
|
|
220
|
+
/** Distance from origin along the wall's normal. Defaults to 0. */
|
|
221
|
+
z?: number;
|
|
222
|
+
/** Spread along world X. Defaults to 10 world units. */
|
|
223
|
+
spreadX?: number;
|
|
224
|
+
/** Spread along world Y. Defaults to 4 world units. */
|
|
225
|
+
spreadY?: number;
|
|
226
|
+
/** Wall vertical center. Defaults to 1.5 world units. */
|
|
227
|
+
centerY?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Hangs panels on a flat virtual wall, centered on the world origin and
|
|
231
|
+
* facing +Z.
|
|
232
|
+
*/
|
|
233
|
+
declare function placeOnWall(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: WallLayoutOpts): void;
|
|
234
|
+
interface ArcLayoutOpts {
|
|
235
|
+
/** Cylinder radius. Defaults to 6. */
|
|
236
|
+
radius?: number;
|
|
237
|
+
/** Total arc spanned in radians. Defaults to π * 0.9 (~160°). */
|
|
238
|
+
arc?: number;
|
|
239
|
+
/** Vertical extent. Defaults to 6. */
|
|
240
|
+
height?: number;
|
|
241
|
+
/** Base Y of the arc. Defaults to 0. */
|
|
242
|
+
baseY?: number;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Wraps DOM x onto an angle around a vertical axis; DOM y becomes height.
|
|
246
|
+
* Same math as `placeOnCylinder` from `./babylon`, exposed here with a
|
|
247
|
+
* clearer name and consistent options shape.
|
|
248
|
+
*/
|
|
249
|
+
declare function placeOnArc(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: ArcLayoutOpts): void;
|
|
250
|
+
interface PathLayoutOpts {
|
|
251
|
+
/** Waypoints along the path. */
|
|
252
|
+
waypoints: Vector3[];
|
|
253
|
+
/** Should each mesh face the next waypoint? Defaults to true. */
|
|
254
|
+
faceForward?: boolean;
|
|
255
|
+
/** Distribute by node index (0..n-1) instead of normalized x. Defaults to false. */
|
|
256
|
+
byIndex?: boolean;
|
|
257
|
+
/** Total node count when using `byIndex`. Defaults to inferred from bounds. */
|
|
258
|
+
nodeCount?: number;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Distributes nodes along a polyline. Each mesh sits on the path; if
|
|
262
|
+
* `faceForward` is true, each mesh's +Y rotation aligns with the path
|
|
263
|
+
* tangent.
|
|
264
|
+
*/
|
|
265
|
+
declare function placeOnPath(node: SceneNode, mesh: Mesh, bounds: Bounds, opts: PathLayoutOpts): void;
|
|
266
|
+
interface SphereLayoutOpts {
|
|
267
|
+
/** Sphere radius. Defaults to 5. */
|
|
268
|
+
radius?: number;
|
|
269
|
+
/** World-space center. Defaults to (0, 0, 0). */
|
|
270
|
+
center?: Vector3;
|
|
271
|
+
/** Latitude span in radians (0..π). Defaults to π * 0.7 (avoids poles). */
|
|
272
|
+
latSpan?: number;
|
|
273
|
+
/** Longitude span in radians (0..2π). Defaults to 2π. */
|
|
274
|
+
lonSpan?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* DOM x → longitude, DOM y → latitude. Useful for "globe of widgets" or
|
|
278
|
+
* any kind of spherical immersive layout.
|
|
279
|
+
*/
|
|
280
|
+
declare function placeOnSphere(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: SphereLayoutOpts): void;
|
|
281
|
+
|
|
191
282
|
/**
|
|
192
283
|
* BabylonJS adapter for `@particle-academy/fancy-3d`.
|
|
193
284
|
*
|
|
@@ -229,4 +320,4 @@ declare function sceneBounds(scene: Scene$1): {
|
|
|
229
320
|
maxY: number;
|
|
230
321
|
};
|
|
231
322
|
|
|
232
|
-
export { type BabylonAdapterDeps, type BillboardOpts, type BoxFace, type BuildingOpts, type Card3DOpts, type CurvedPanelOpts, type CylinderOpts, type DecalOpts, type DiscOpts, type MonitorOpts, type MonitorResult, type PaintFn, type PanelOpts, type PillarOpts, type SignOpts, type SignResult, type SphereOpts, type SurfaceContent, TEX_SCALE, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnCylinder, sceneBounds };
|
|
323
|
+
export { type ArcLayoutOpts, type BabylonAdapterDeps, type BillboardOpts, type BoxFace, type BuildingOpts, type Card3DOpts, type CurvedPanelOpts, type CylinderOpts, type DecalOpts, type DiscOpts, type GridLayoutOpts, type MonitorOpts, type MonitorResult, type PaintFn, type PanelOpts, type PathLayoutOpts, type PillarOpts, type SignOpts, type SignResult, type SphereLayoutOpts, type SphereOpts, type SurfaceContent, TEX_SCALE, type WallLayoutOpts, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnArc, placeOnCylinder, placeOnGrid, placeOnPath, placeOnSphere, placeOnWall, sceneBounds };
|
package/dist/babylon.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scene, Mesh, Vector3, DynamicTexture } from '@babylonjs/core';
|
|
2
|
-
import { WidgetSpec,
|
|
2
|
+
import { j as WidgetSpec, f as SceneNode, W as WidgetAdapter, S as Scene$1 } from './scene-ChcFkvmm.js';
|
|
3
3
|
|
|
4
4
|
declare const TEX_SCALE = 2;
|
|
5
5
|
declare function paintWidget(ctx: CanvasRenderingContext2D, spec: WidgetSpec, w: number, h: number, selected: boolean): void;
|
|
@@ -188,6 +188,97 @@ interface DecalOpts {
|
|
|
188
188
|
declare function createDecal(opts: DecalOpts): Mesh;
|
|
189
189
|
declare function createWidgetTexture(scene: Scene, name: string, widget: WidgetSpec, pixelWidth: number, pixelHeight: number, selected?: boolean): DynamicTexture;
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Layout helpers — map 2D scene-node positions onto 3D arrangements.
|
|
193
|
+
*
|
|
194
|
+
* All layout functions take the same shape: a SceneNode, the Mesh that was
|
|
195
|
+
* built for it, the scene's bounds, and layout-specific options. They mutate
|
|
196
|
+
* `mesh.position` (and sometimes `mesh.rotation`) in place.
|
|
197
|
+
*
|
|
198
|
+
* Pair with `sceneBounds(scene)` from `./babylon` to compute the bounds.
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
interface Bounds {
|
|
202
|
+
minX: number;
|
|
203
|
+
maxX: number;
|
|
204
|
+
minY: number;
|
|
205
|
+
maxY: number;
|
|
206
|
+
}
|
|
207
|
+
interface GridLayoutOpts {
|
|
208
|
+
/** Pixel-to-world unit ratio. Defaults to 1/120. */
|
|
209
|
+
scale?: number;
|
|
210
|
+
/** World-space center of the grid. Defaults to (0, 0, 0). */
|
|
211
|
+
origin?: Vector3;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Direct 2D-to-3D mapping. DOM (x, y) becomes world (x, -y, 0) — the most
|
|
215
|
+
* literal layout. Useful when you want the scene to look identical to its
|
|
216
|
+
* DOM rendering, just rendered as floating panels.
|
|
217
|
+
*/
|
|
218
|
+
declare function placeOnGrid(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: GridLayoutOpts): void;
|
|
219
|
+
interface WallLayoutOpts {
|
|
220
|
+
/** Distance from origin along the wall's normal. Defaults to 0. */
|
|
221
|
+
z?: number;
|
|
222
|
+
/** Spread along world X. Defaults to 10 world units. */
|
|
223
|
+
spreadX?: number;
|
|
224
|
+
/** Spread along world Y. Defaults to 4 world units. */
|
|
225
|
+
spreadY?: number;
|
|
226
|
+
/** Wall vertical center. Defaults to 1.5 world units. */
|
|
227
|
+
centerY?: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Hangs panels on a flat virtual wall, centered on the world origin and
|
|
231
|
+
* facing +Z.
|
|
232
|
+
*/
|
|
233
|
+
declare function placeOnWall(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: WallLayoutOpts): void;
|
|
234
|
+
interface ArcLayoutOpts {
|
|
235
|
+
/** Cylinder radius. Defaults to 6. */
|
|
236
|
+
radius?: number;
|
|
237
|
+
/** Total arc spanned in radians. Defaults to π * 0.9 (~160°). */
|
|
238
|
+
arc?: number;
|
|
239
|
+
/** Vertical extent. Defaults to 6. */
|
|
240
|
+
height?: number;
|
|
241
|
+
/** Base Y of the arc. Defaults to 0. */
|
|
242
|
+
baseY?: number;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Wraps DOM x onto an angle around a vertical axis; DOM y becomes height.
|
|
246
|
+
* Same math as `placeOnCylinder` from `./babylon`, exposed here with a
|
|
247
|
+
* clearer name and consistent options shape.
|
|
248
|
+
*/
|
|
249
|
+
declare function placeOnArc(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: ArcLayoutOpts): void;
|
|
250
|
+
interface PathLayoutOpts {
|
|
251
|
+
/** Waypoints along the path. */
|
|
252
|
+
waypoints: Vector3[];
|
|
253
|
+
/** Should each mesh face the next waypoint? Defaults to true. */
|
|
254
|
+
faceForward?: boolean;
|
|
255
|
+
/** Distribute by node index (0..n-1) instead of normalized x. Defaults to false. */
|
|
256
|
+
byIndex?: boolean;
|
|
257
|
+
/** Total node count when using `byIndex`. Defaults to inferred from bounds. */
|
|
258
|
+
nodeCount?: number;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Distributes nodes along a polyline. Each mesh sits on the path; if
|
|
262
|
+
* `faceForward` is true, each mesh's +Y rotation aligns with the path
|
|
263
|
+
* tangent.
|
|
264
|
+
*/
|
|
265
|
+
declare function placeOnPath(node: SceneNode, mesh: Mesh, bounds: Bounds, opts: PathLayoutOpts): void;
|
|
266
|
+
interface SphereLayoutOpts {
|
|
267
|
+
/** Sphere radius. Defaults to 5. */
|
|
268
|
+
radius?: number;
|
|
269
|
+
/** World-space center. Defaults to (0, 0, 0). */
|
|
270
|
+
center?: Vector3;
|
|
271
|
+
/** Latitude span in radians (0..π). Defaults to π * 0.7 (avoids poles). */
|
|
272
|
+
latSpan?: number;
|
|
273
|
+
/** Longitude span in radians (0..2π). Defaults to 2π. */
|
|
274
|
+
lonSpan?: number;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* DOM x → longitude, DOM y → latitude. Useful for "globe of widgets" or
|
|
278
|
+
* any kind of spherical immersive layout.
|
|
279
|
+
*/
|
|
280
|
+
declare function placeOnSphere(node: SceneNode, mesh: Mesh, bounds: Bounds, opts?: SphereLayoutOpts): void;
|
|
281
|
+
|
|
191
282
|
/**
|
|
192
283
|
* BabylonJS adapter for `@particle-academy/fancy-3d`.
|
|
193
284
|
*
|
|
@@ -229,4 +320,4 @@ declare function sceneBounds(scene: Scene$1): {
|
|
|
229
320
|
maxY: number;
|
|
230
321
|
};
|
|
231
322
|
|
|
232
|
-
export { type BabylonAdapterDeps, type BillboardOpts, type BoxFace, type BuildingOpts, type Card3DOpts, type CurvedPanelOpts, type CylinderOpts, type DecalOpts, type DiscOpts, type MonitorOpts, type MonitorResult, type PaintFn, type PanelOpts, type PillarOpts, type SignOpts, type SignResult, type SphereOpts, type SurfaceContent, TEX_SCALE, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnCylinder, sceneBounds };
|
|
323
|
+
export { type ArcLayoutOpts, type BabylonAdapterDeps, type BillboardOpts, type BoxFace, type BuildingOpts, type Card3DOpts, type CurvedPanelOpts, type CylinderOpts, type DecalOpts, type DiscOpts, type GridLayoutOpts, type MonitorOpts, type MonitorResult, type PaintFn, type PanelOpts, type PathLayoutOpts, type PillarOpts, type SignOpts, type SignResult, type SphereLayoutOpts, type SphereOpts, type SurfaceContent, TEX_SCALE, type WallLayoutOpts, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnArc, placeOnCylinder, placeOnGrid, placeOnPath, placeOnSphere, placeOnWall, sceneBounds };
|
package/dist/babylon.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import './chunk-DGUM43GV.js';
|
|
1
2
|
import { MeshBuilder, Mesh, DynamicTexture, Vector4, StandardMaterial, Color3, Vector3 } from '@babylonjs/core';
|
|
2
3
|
|
|
3
|
-
// src/babylon.ts
|
|
4
|
-
|
|
5
4
|
// src/painters.ts
|
|
6
5
|
var TEX_SCALE = 2;
|
|
7
6
|
function unitOf(_w, h) {
|
|
@@ -698,6 +697,87 @@ function createWidgetTexture(scene, name, widget, pixelWidth, pixelHeight, selec
|
|
|
698
697
|
tex.update(false);
|
|
699
698
|
return tex;
|
|
700
699
|
}
|
|
700
|
+
function sizeOf(node) {
|
|
701
|
+
return { w: node.size?.w ?? 200, h: node.size?.h ?? 120 };
|
|
702
|
+
}
|
|
703
|
+
function normalizedCenter(node, bounds) {
|
|
704
|
+
const { w, h } = sizeOf(node);
|
|
705
|
+
const cx = (node.position.x + w / 2 - bounds.minX) / Math.max(1, bounds.maxX - bounds.minX);
|
|
706
|
+
const cy = (node.position.y + h / 2 - bounds.minY) / Math.max(1, bounds.maxY - bounds.minY);
|
|
707
|
+
return { cx, cy };
|
|
708
|
+
}
|
|
709
|
+
function placeOnGrid(node, mesh, bounds, opts = {}) {
|
|
710
|
+
const scale = opts.scale ?? 1 / 120;
|
|
711
|
+
const origin = opts.origin ?? new Vector3(0, 0, 0);
|
|
712
|
+
const { w, h } = sizeOf(node);
|
|
713
|
+
const cx = node.position.x + w / 2 - (bounds.minX + bounds.maxX) / 2;
|
|
714
|
+
const cy = node.position.y + h / 2 - (bounds.minY + bounds.maxY) / 2;
|
|
715
|
+
mesh.position = new Vector3(origin.x + cx * scale, origin.y - cy * scale, origin.z);
|
|
716
|
+
}
|
|
717
|
+
function placeOnWall(node, mesh, bounds, opts = {}) {
|
|
718
|
+
const spreadX = opts.spreadX ?? 10;
|
|
719
|
+
const spreadY = opts.spreadY ?? 4;
|
|
720
|
+
const centerY = opts.centerY ?? 1.5;
|
|
721
|
+
const z = opts.z ?? 0;
|
|
722
|
+
const { cx, cy } = normalizedCenter(node, bounds);
|
|
723
|
+
mesh.position = new Vector3((cx - 0.5) * spreadX, centerY + (0.5 - cy) * spreadY, z);
|
|
724
|
+
mesh.rotation.y = 0;
|
|
725
|
+
}
|
|
726
|
+
function placeOnArc(node, mesh, bounds, opts = {}) {
|
|
727
|
+
const radius = opts.radius ?? 6;
|
|
728
|
+
const arc = opts.arc ?? Math.PI * 0.9;
|
|
729
|
+
const height = opts.height ?? 6;
|
|
730
|
+
const baseY = opts.baseY ?? 0;
|
|
731
|
+
const { cx, cy } = normalizedCenter(node, bounds);
|
|
732
|
+
const angle = (cx - 0.5) * arc;
|
|
733
|
+
mesh.position = new Vector3(Math.sin(angle) * radius, baseY + (0.5 - cy) * height, Math.cos(angle) * radius);
|
|
734
|
+
mesh.rotation.y = angle;
|
|
735
|
+
}
|
|
736
|
+
function lerpPath(waypoints, t) {
|
|
737
|
+
if (waypoints.length === 0) return { pos: new Vector3(0, 0, 0), tangent: new Vector3(0, 0, 1) };
|
|
738
|
+
if (waypoints.length === 1) return { pos: waypoints[0].clone(), tangent: new Vector3(0, 0, 1) };
|
|
739
|
+
const segments = waypoints.length - 1;
|
|
740
|
+
const scaled = Math.max(0, Math.min(1, t)) * segments;
|
|
741
|
+
const i = Math.min(segments - 1, Math.floor(scaled));
|
|
742
|
+
const local = scaled - i;
|
|
743
|
+
const a = waypoints[i];
|
|
744
|
+
const b = waypoints[i + 1];
|
|
745
|
+
const pos = Vector3.Lerp(a, b, local);
|
|
746
|
+
const tangent = b.subtract(a).normalize();
|
|
747
|
+
return { pos, tangent };
|
|
748
|
+
}
|
|
749
|
+
function placeOnPath(node, mesh, bounds, opts) {
|
|
750
|
+
const faceForward = opts.faceForward ?? true;
|
|
751
|
+
let t;
|
|
752
|
+
if (opts.byIndex) {
|
|
753
|
+
const total = opts.nodeCount ?? Math.max(1, bounds.maxX - bounds.minX);
|
|
754
|
+
const idx = node.position.x;
|
|
755
|
+
t = total > 1 ? idx / (total - 1) : 0.5;
|
|
756
|
+
} else {
|
|
757
|
+
const { cx } = normalizedCenter(node, bounds);
|
|
758
|
+
t = cx;
|
|
759
|
+
}
|
|
760
|
+
const { pos, tangent } = lerpPath(opts.waypoints, t);
|
|
761
|
+
mesh.position = pos;
|
|
762
|
+
if (faceForward) {
|
|
763
|
+
mesh.rotation.y = Math.atan2(tangent.x, tangent.z);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
function placeOnSphere(node, mesh, bounds, opts = {}) {
|
|
767
|
+
const radius = opts.radius ?? 5;
|
|
768
|
+
const center = opts.center ?? new Vector3(0, 0, 0);
|
|
769
|
+
const latSpan = opts.latSpan ?? Math.PI * 0.7;
|
|
770
|
+
const lonSpan = opts.lonSpan ?? Math.PI * 2;
|
|
771
|
+
const { cx, cy } = normalizedCenter(node, bounds);
|
|
772
|
+
const lon = (cx - 0.5) * lonSpan;
|
|
773
|
+
const lat = (0.5 - cy) * latSpan;
|
|
774
|
+
const r = radius;
|
|
775
|
+
const x = r * Math.cos(lat) * Math.sin(lon);
|
|
776
|
+
const y = r * Math.sin(lat);
|
|
777
|
+
const z = r * Math.cos(lat) * Math.cos(lon);
|
|
778
|
+
mesh.position = new Vector3(center.x + x, center.y + y, center.z + z);
|
|
779
|
+
mesh.rotation.y = lon;
|
|
780
|
+
}
|
|
701
781
|
|
|
702
782
|
// src/babylon.ts
|
|
703
783
|
var WORLD_SCALE = 1 / 180;
|
|
@@ -751,6 +831,6 @@ function sceneBounds(scene) {
|
|
|
751
831
|
};
|
|
752
832
|
}
|
|
753
833
|
|
|
754
|
-
export { TEX_SCALE, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnCylinder, sceneBounds };
|
|
834
|
+
export { TEX_SCALE, createBabylonAdapter, createBillboard, createBuilding, createCard3D, createCurvedPanel, createCylinder, createDecal, createDisc, createMonitor, createPanel, createPillar, createSign, createSphere, createWidgetTexture, paintWidget, placeOnArc, placeOnCylinder, placeOnGrid, placeOnPath, placeOnSphere, placeOnWall, sceneBounds };
|
|
755
835
|
//# sourceMappingURL=babylon.js.map
|
|
756
836
|
//# sourceMappingURL=babylon.js.map
|