@3driseai/3drise-viewer 0.1.29 → 0.1.31
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/animationsV2/ClipPlayer.d.ts.map +1 -1
- package/dist/animationsV2/ClipPlayer.js +14 -12
- package/dist/animationsV2/ClipsRuntime.d.ts +13 -0
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +115 -4
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +21 -2
- package/dist/animationsV2/clipUtils.d.ts.map +1 -1
- package/dist/animationsV2/clipUtils.js +5 -1
- package/dist/animationsV2/sequenceUtils.d.ts +5 -0
- package/dist/animationsV2/sequenceUtils.d.ts.map +1 -1
- package/dist/animationsV2/sequenceUtils.js +14 -5
- package/dist/animationsV2/sunSystemLive.d.ts +12 -0
- package/dist/animationsV2/sunSystemLive.d.ts.map +1 -0
- package/dist/animationsV2/sunSystemLive.js +8 -0
- package/dist/animationsV2/types.d.ts +6 -0
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.d.ts +3 -1
- package/dist/api/sceneHandle.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +2 -2
- package/dist/components/AdaptiveResolution.d.ts +9 -0
- package/dist/components/AdaptiveResolution.d.ts.map +1 -0
- package/dist/components/AdaptiveResolution.js +61 -0
- package/dist/components/CameraController.d.ts.map +1 -1
- package/dist/components/CameraController.js +24 -7
- package/dist/components/EffectsGenerator.d.ts.map +1 -1
- package/dist/components/EffectsGenerator.js +43 -38
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +22 -2
- package/dist/components/MoonDisc.d.ts.map +1 -1
- package/dist/components/MoonDisc.js +2 -1
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +6 -17
- package/dist/components/OceanBuilder.d.ts +4 -1
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -1
- package/dist/components/ParticlesGenerator.d.ts.map +1 -1
- package/dist/components/ParticlesGenerator.js +46 -24
- package/dist/components/PickVolume.d.ts +17 -0
- package/dist/components/PickVolume.d.ts.map +1 -0
- package/dist/components/PickVolume.js +20 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +5 -2
- package/dist/components/SkyStars.d.ts.map +1 -1
- package/dist/components/SkyStars.js +83 -2
- package/dist/components/Skybox.d.ts.map +1 -1
- package/dist/components/Skybox.js +2 -1
- package/dist/components/SunLight.d.ts.map +1 -1
- package/dist/components/SunLight.js +3 -2
- package/dist/components/TextGenerator.d.ts.map +1 -1
- package/dist/components/TextGenerator.js +3 -2
- package/dist/components/index.d.ts +2 -8
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -4
- package/dist/components/lightBulb/LightBulb.d.ts.map +1 -1
- package/dist/components/lightBulb/LightBulb.js +7 -2
- package/dist/components/particles/BioluminescentWakeParticles.d.ts +5 -0
- package/dist/components/particles/BioluminescentWakeParticles.d.ts.map +1 -1
- package/dist/components/particles/BioluminescentWakeParticles.js +2 -1
- package/dist/components/particles/BrownianDustParticles.d.ts +5 -0
- package/dist/components/particles/BrownianDustParticles.d.ts.map +1 -1
- package/dist/components/particles/BrownianDustParticles.js +2 -0
- package/dist/components/particles/ChladniSandParticles.d.ts +5 -0
- package/dist/components/particles/ChladniSandParticles.d.ts.map +1 -1
- package/dist/components/particles/ChladniSandParticles.js +2 -1
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts +5 -0
- package/dist/components/particles/ElectronOrbitalsParticles.d.ts.map +1 -1
- package/dist/components/particles/ElectronOrbitalsParticles.js +2 -1
- package/dist/components/particles/FaradayPowderParticles.d.ts +5 -0
- package/dist/components/particles/FaradayPowderParticles.d.ts.map +1 -1
- package/dist/components/particles/FaradayPowderParticles.js +2 -1
- package/dist/components/particles/FireworksParticles.d.ts +22 -0
- package/dist/components/particles/FireworksParticles.d.ts.map +1 -0
- package/dist/components/particles/FireworksParticles.js +1649 -0
- package/dist/components/particles/GrinderSparksParticles.d.ts +5 -0
- package/dist/components/particles/GrinderSparksParticles.d.ts.map +1 -1
- package/dist/components/particles/GrinderSparksParticles.js +2 -1
- package/dist/components/particles/MagneticBottleParticles.d.ts +5 -0
- package/dist/components/particles/MagneticBottleParticles.d.ts.map +1 -1
- package/dist/components/particles/MagneticBottleParticles.js +2 -1
- package/dist/components/particles/NeonRainParticles.d.ts +5 -0
- package/dist/components/particles/NeonRainParticles.d.ts.map +1 -1
- package/dist/components/particles/NeonRainParticles.js +2 -1
- package/dist/components/particles/ShapeBurstParticles.d.ts +5 -0
- package/dist/components/particles/ShapeBurstParticles.d.ts.map +1 -1
- package/dist/components/particles/ShapeBurstParticles.js +2 -1
- package/dist/components/particles/ShapeFlowParticles.d.ts +5 -0
- package/dist/components/particles/ShapeFlowParticles.d.ts.map +1 -1
- package/dist/components/particles/ShapeFlowParticles.js +2 -1
- package/dist/components/particles/TidalStreamParticles.d.ts +5 -0
- package/dist/components/particles/TidalStreamParticles.d.ts.map +1 -1
- package/dist/components/particles/TidalStreamParticles.js +2 -0
- package/dist/components/particles/index.d.ts +2 -0
- package/dist/components/particles/index.d.ts.map +1 -1
- package/dist/components/particles/index.js +1 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +26 -4
- package/dist/components/text/PlainText.d.ts +15 -0
- package/dist/components/text/PlainText.d.ts.map +1 -0
- package/dist/components/text/PlainText.js +4 -0
- package/dist/components/text/TextObjectView.d.ts +3 -1
- package/dist/components/text/TextObjectView.d.ts.map +1 -1
- package/dist/components/text/TextObjectView.js +9 -3
- package/dist/components/text/engine/looks/index.d.ts.map +1 -1
- package/dist/components/text/engine/looks/index.js +2 -1
- package/dist/components/text/engine/looks/plain.d.ts +146 -0
- package/dist/components/text/engine/looks/plain.d.ts.map +1 -0
- package/dist/components/text/engine/looks/plain.js +104 -0
- package/dist/components/text/fonts/bebas-neue.outline.d.ts +3 -0
- package/dist/components/text/fonts/bebas-neue.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/bebas-neue.outline.js +4 -0
- package/dist/components/text/fonts/bebas-neue.strokes.d.ts +3 -0
- package/dist/components/text/fonts/bebas-neue.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/bebas-neue.strokes.js +4 -0
- package/dist/components/text/fonts/index.d.ts +1 -1
- package/dist/components/text/fonts/index.d.ts.map +1 -1
- package/dist/components/text/fonts/index.js +15 -1
- package/dist/components/text/fonts/inter.outline.d.ts +3 -0
- package/dist/components/text/fonts/inter.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/inter.outline.js +4 -0
- package/dist/components/text/fonts/inter.strokes.d.ts +3 -0
- package/dist/components/text/fonts/inter.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/inter.strokes.js +4 -0
- package/dist/components/text/fonts/lora.outline.d.ts +3 -0
- package/dist/components/text/fonts/lora.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/lora.outline.js +4 -0
- package/dist/components/text/fonts/lora.strokes.d.ts +3 -0
- package/dist/components/text/fonts/lora.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/lora.strokes.js +4 -0
- package/dist/components/text/fonts/montserrat.outline.d.ts +3 -0
- package/dist/components/text/fonts/montserrat.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/montserrat.outline.js +4 -0
- package/dist/components/text/fonts/montserrat.strokes.d.ts +3 -0
- package/dist/components/text/fonts/montserrat.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/montserrat.strokes.js +4 -0
- package/dist/components/text/fonts/oswald.outline.d.ts +3 -0
- package/dist/components/text/fonts/oswald.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/oswald.outline.js +4 -0
- package/dist/components/text/fonts/oswald.strokes.d.ts +3 -0
- package/dist/components/text/fonts/oswald.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/oswald.strokes.js +4 -0
- package/dist/components/text/fonts/playfair-display.outline.d.ts +3 -0
- package/dist/components/text/fonts/playfair-display.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/playfair-display.outline.js +4 -0
- package/dist/components/text/fonts/playfair-display.strokes.d.ts +3 -0
- package/dist/components/text/fonts/playfair-display.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/playfair-display.strokes.js +4 -0
- package/dist/components/text/fonts/roboto.outline.d.ts +3 -0
- package/dist/components/text/fonts/roboto.outline.d.ts.map +1 -0
- package/dist/components/text/fonts/roboto.outline.js +4 -0
- package/dist/components/text/fonts/roboto.strokes.d.ts +3 -0
- package/dist/components/text/fonts/roboto.strokes.d.ts.map +1 -0
- package/dist/components/text/fonts/roboto.strokes.js +4 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.d.ts.map +1 -1
- package/dist/components/text/index.js +1 -0
- package/dist/components/text/useTextObject.d.ts +1 -0
- package/dist/components/text/useTextObject.d.ts.map +1 -1
- package/dist/components/text/useTextObject.js +23 -11
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +5 -1
- package/dist/components/water/types.d.ts +3 -1
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/hooks/useOceanMaterial.d.ts +6 -2
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +22 -2
- package/dist/hooks/useOrbitTargetFollow.d.ts +10 -0
- package/dist/hooks/useOrbitTargetFollow.d.ts.map +1 -0
- package/dist/hooks/useOrbitTargetFollow.js +194 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/operations/catalogue/flock.d.ts.map +1 -1
- package/dist/operations/catalogue/flock.js +44 -9
- package/dist/operations/catalogue/inkBloom.d.ts.map +1 -1
- package/dist/operations/catalogue/inkBloom.js +46 -9
- package/dist/operations/catalogue/liquidMetal.d.ts.map +1 -1
- package/dist/operations/catalogue/liquidMetal.js +41 -12
- package/dist/operations/catalogue/particleSwarm.d.ts.map +1 -1
- package/dist/operations/catalogue/particleSwarm.js +29 -9
- package/dist/operations/catalogue/petalPeel.d.ts.map +1 -1
- package/dist/operations/catalogue/petalPeel.js +33 -9
- package/dist/operations/catalogue/portal.d.ts.map +1 -1
- package/dist/operations/catalogue/portal.js +33 -11
- package/dist/operations/catalogue/sandErosion.d.ts.map +1 -1
- package/dist/operations/catalogue/sandErosion.js +36 -14
- package/dist/operations/catalogue/teleport.d.ts.map +1 -1
- package/dist/operations/catalogue/teleport.js +43 -12
- package/dist/operations/catalogue/unweave.d.ts.map +1 -1
- package/dist/operations/catalogue/unweave.js +34 -15
- package/dist/operations/catalogue/voxelize.d.ts.map +1 -1
- package/dist/operations/catalogue/voxelize.js +37 -10
- package/dist/shaders/glsl/terrainCore.glsl.d.ts +18 -3
- package/dist/shaders/glsl/terrainCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/terrainCore.glsl.js +42 -21
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +36 -11
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +96 -5
- package/dist/triggers/engine.d.ts +1 -1
- package/dist/triggers/engine.d.ts.map +1 -1
- package/dist/triggers/engine.js +3 -0
- package/dist/triggers/hosts/actions.d.ts.map +1 -1
- package/dist/triggers/hosts/actions.js +3 -1
- package/dist/triggers/hosts/interactions.d.ts.map +1 -1
- package/dist/triggers/hosts/interactions.js +1 -1
- package/dist/triggers/hosts/timelineCues.js +1 -1
- package/dist/triggers/kinds/change.d.ts +4 -0
- package/dist/triggers/kinds/change.d.ts.map +1 -0
- package/dist/triggers/kinds/change.js +50 -0
- package/dist/triggers/kinds/index.d.ts +1 -0
- package/dist/triggers/kinds/index.d.ts.map +1 -1
- package/dist/triggers/kinds/index.js +1 -0
- package/dist/utils/CameraSingleton.d.ts +4 -0
- package/dist/utils/CameraSingleton.d.ts.map +1 -1
- package/dist/utils/CameraSingleton.js +4 -0
- package/dist/utils/deviceTier.d.ts +2 -0
- package/dist/utils/deviceTier.d.ts.map +1 -0
- package/dist/utils/deviceTier.js +16 -0
- package/dist/utils/environmentDrawOrder.d.ts +23 -0
- package/dist/utils/environmentDrawOrder.d.ts.map +1 -0
- package/dist/utils/environmentDrawOrder.js +22 -0
- package/dist/utils/pickProxy.d.ts +11 -0
- package/dist/utils/pickProxy.d.ts.map +1 -0
- package/dist/utils/pickProxy.js +36 -0
- package/dist/utils/shapes.d.ts +4 -0
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +4 -1
- package/dist/utils/terrainUniforms.d.ts +7 -0
- package/dist/utils/terrainUniforms.d.ts.map +1 -1
- package/dist/utils/terrainUniforms.js +15 -2
- package/dist/utils/textShape.d.ts +24 -0
- package/dist/utils/textShape.d.ts.map +1 -0
- package/dist/utils/textShape.js +102 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraSingleton.d.ts","sourceRoot":"","sources":["../../src/utils/CameraSingleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAsB,OAAO,EAAE,KAAK,EAAc,MAAM,OAAO,CAAC;AAC1F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAExF,cAAM,eAAe;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;IACxB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,YAAY,CAAe;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IAChB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAI3C,OAAO,CAAC,eAAe;IAGvB,WAAW,IAAI,OAAO;IACtB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM;IAG5C,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAM7B,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG;QAC9C,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAClB;IAeT,wBAAwB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG;QAC5B,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,EAAE,OAAO,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC;KACnB;IAqBT,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,OAAO,GAAE,MAAU,GAAG,OAAO;IA6CvH,YAAY,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI;IAIhF,mBAAmB,CAAC,OAAO,GAAE,MAAc,GAAG,OAAO;CAiBxD;AACD,eAAO,MAAM,aAAa,EAAE,eAA+C,CAAC;AAC5E,eAAe,aAAa,CAAC"}
|
|
@@ -43,6 +43,10 @@ class CameraSingleton {
|
|
|
43
43
|
this.notifyCallbacks();
|
|
44
44
|
}
|
|
45
45
|
getCamera() { return this.camera; }
|
|
46
|
+
/** The live OrbitControls (registered by CameraController) — controllers drag it directly. */
|
|
47
|
+
controls = null;
|
|
48
|
+
setControls(controls) { this.controls = controls; }
|
|
49
|
+
getControls() { return this.controls; }
|
|
46
50
|
getPosition() { return this.camera ? this.camera.position.clone() : new Vector3(); }
|
|
47
51
|
getRotation() { return this.camera ? this.camera.rotation.clone() : new Euler(); }
|
|
48
52
|
isSynced(position, orientation) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTier.d.ts","sourceRoot":"","sources":["../../src/utils/deviceTier.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,IAAI,OAAO,CAOxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coarse device tier, for render-time quality caps. A phone or tablet: a coarse
|
|
3
|
+
* primary pointer on a small screen. Read once — it does not change while a page
|
|
4
|
+
* is open, and render code must not branch on something that flickers.
|
|
5
|
+
*/
|
|
6
|
+
let cached = null;
|
|
7
|
+
export function isMobileDevice() {
|
|
8
|
+
if (cached !== null)
|
|
9
|
+
return cached;
|
|
10
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
11
|
+
return (cached = false);
|
|
12
|
+
const coarse = window.matchMedia('(pointer: coarse)').matches;
|
|
13
|
+
const shortSide = Math.min(window.screen?.width ?? 0, window.screen?.height ?? 0);
|
|
14
|
+
cached = coarse && shortSide > 0 && shortSide < 1000;
|
|
15
|
+
return cached;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draw order of the camera-centred environment surfaces.
|
|
3
|
+
*
|
|
4
|
+
* three sorts opaque objects by renderOrder, then by MATERIAL ID, then by depth.
|
|
5
|
+
* The world ocean and the terrain clipmaps are both centred on the camera, so the
|
|
6
|
+
* depth tie never helps, and with renderOrder left at 0 the material id decides:
|
|
7
|
+
* whichever surface was created last draws last. That made the frame cost depend
|
|
8
|
+
* on mount order — measured 13 ms vs 22-27 ms GPU in the same view — because when
|
|
9
|
+
* the terrain drew first, every terrain pixel under the sea ran the full terrain
|
|
10
|
+
* shader (textures, 8 noise octaves) and was then painted over by water.
|
|
11
|
+
*
|
|
12
|
+
* Fixed order instead, all below the scene's objects (0):
|
|
13
|
+
* 1. water, inner rings first (cheap shader; hides the seabed from the depth test)
|
|
14
|
+
* 2. terrain, inner rings first (near ground hides far ground: front to back)
|
|
15
|
+
* Drawing near-to-far is what lets the early depth test throw hidden pixels away
|
|
16
|
+
* before their shader runs. Wasted water pixels behind land are cheap; wasted
|
|
17
|
+
* terrain pixels under water were most of the frame.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OCEAN_DRAW_ORDER = -40;
|
|
20
|
+
export declare const TERRAIN_DRAW_ORDER = -20;
|
|
21
|
+
/** Inner ring (level 0) first, then outward. */
|
|
22
|
+
export declare const ringDrawOrder: (base: number, level: number) => number;
|
|
23
|
+
//# sourceMappingURL=environmentDrawOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environmentDrawOrder.d.ts","sourceRoot":"","sources":["../../src/utils/environmentDrawOrder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,gDAAgD;AAChD,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,WAAiB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draw order of the camera-centred environment surfaces.
|
|
3
|
+
*
|
|
4
|
+
* three sorts opaque objects by renderOrder, then by MATERIAL ID, then by depth.
|
|
5
|
+
* The world ocean and the terrain clipmaps are both centred on the camera, so the
|
|
6
|
+
* depth tie never helps, and with renderOrder left at 0 the material id decides:
|
|
7
|
+
* whichever surface was created last draws last. That made the frame cost depend
|
|
8
|
+
* on mount order — measured 13 ms vs 22-27 ms GPU in the same view — because when
|
|
9
|
+
* the terrain drew first, every terrain pixel under the sea ran the full terrain
|
|
10
|
+
* shader (textures, 8 noise octaves) and was then painted over by water.
|
|
11
|
+
*
|
|
12
|
+
* Fixed order instead, all below the scene's objects (0):
|
|
13
|
+
* 1. water, inner rings first (cheap shader; hides the seabed from the depth test)
|
|
14
|
+
* 2. terrain, inner rings first (near ground hides far ground: front to back)
|
|
15
|
+
* Drawing near-to-far is what lets the early depth test throw hidden pixels away
|
|
16
|
+
* before their shader runs. Wasted water pixels behind land are cheap; wasted
|
|
17
|
+
* terrain pixels under water were most of the frame.
|
|
18
|
+
*/
|
|
19
|
+
export const OCEAN_DRAW_ORDER = -40;
|
|
20
|
+
export const TERRAIN_DRAW_ORDER = -20;
|
|
21
|
+
/** Inner ring (level 0) first, then outward. */
|
|
22
|
+
export const ringDrawOrder = (base, level) => base + level;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export declare const PICK_PROXY_NAME = "pickProxy";
|
|
3
|
+
export declare function pickMaterial(side?: THREE.Side): THREE.MeshBasicMaterial;
|
|
4
|
+
/** A unit plane proxy (scale it to the object's extent). */
|
|
5
|
+
export declare function pickPlane(): THREE.Mesh;
|
|
6
|
+
/** A unit sphere proxy (scale it to the object's radius). Front faces only: one hit per ray from outside. */
|
|
7
|
+
export declare function pickSphere(): THREE.Mesh;
|
|
8
|
+
export declare const NO_RAYCAST: () => any;
|
|
9
|
+
/** Takes every object under `root` out of raycasting (the proxy is the hit target). Idempotent and cheap: safe per frame. */
|
|
10
|
+
export declare function stopRaycast(root: THREE.Object3D): void;
|
|
11
|
+
//# sourceMappingURL=pickProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickProxy.d.ts","sourceRoot":"","sources":["../../src/utils/pickProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,wBAAgB,YAAY,CAAC,IAAI,GAAE,KAAK,CAAC,IAAuB,GAAG,KAAK,CAAC,iBAAiB,CAEzF;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,IAAI,KAAK,CAAC,IAAI,CAItC;AAED,6GAA6G;AAC7G,wBAAgB,UAAU,IAAI,KAAK,CAAC,IAAI,CAIvC;AAED,eAAO,MAAM,UAAU,WAAa,CAAC;AACrC,6HAA6H;AAC7H,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAEtD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Pick proxy — one invisible hit shape per object, so hover / click (the Actions tab's triggers, selection)
|
|
4
|
+
// react to the object as a whole instead of to whatever its shaders happen to draw: a text hits on its box,
|
|
5
|
+
// not letter by letter; a particle cloud on its volume, not on one sprite.
|
|
6
|
+
//
|
|
7
|
+
// The proxy is a real mesh that draws nothing (colorWrite / depthWrite off) — not `visible: false`, which the
|
|
8
|
+
// event layer skips. The object's own drawing meshes opt out of raycasting (`stopRaycast`) so the proxy is the
|
|
9
|
+
// only thing the pointer can land on. Its geometry also gives the selection gizmo a true bounding box.
|
|
10
|
+
// =============================================================================
|
|
11
|
+
export const PICK_PROXY_NAME = 'pickProxy';
|
|
12
|
+
export function pickMaterial(side = THREE.DoubleSide) {
|
|
13
|
+
return new THREE.MeshBasicMaterial({ colorWrite: false, depthWrite: false, side });
|
|
14
|
+
}
|
|
15
|
+
/** A unit plane proxy (scale it to the object's extent). */
|
|
16
|
+
export function pickPlane() {
|
|
17
|
+
const m = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), pickMaterial());
|
|
18
|
+
m.name = PICK_PROXY_NAME;
|
|
19
|
+
m.frustumCulled = false;
|
|
20
|
+
m.renderOrder = -1000;
|
|
21
|
+
return m;
|
|
22
|
+
}
|
|
23
|
+
/** A unit sphere proxy (scale it to the object's radius). Front faces only: one hit per ray from outside. */
|
|
24
|
+
export function pickSphere() {
|
|
25
|
+
const m = new THREE.Mesh(new THREE.SphereGeometry(1, 12, 8), pickMaterial(THREE.FrontSide));
|
|
26
|
+
m.name = PICK_PROXY_NAME;
|
|
27
|
+
m.frustumCulled = false;
|
|
28
|
+
m.renderOrder = -1000;
|
|
29
|
+
return m;
|
|
30
|
+
}
|
|
31
|
+
export const NO_RAYCAST = () => null;
|
|
32
|
+
/** Takes every object under `root` out of raycasting (the proxy is the hit target). Idempotent and cheap: safe per frame. */
|
|
33
|
+
export function stopRaycast(root) {
|
|
34
|
+
root.traverse((o) => { if (o.raycast !== NO_RAYCAST)
|
|
35
|
+
o.raycast = NO_RAYCAST; });
|
|
36
|
+
}
|
package/dist/utils/shapes.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export interface ShapeOptions {
|
|
|
39
39
|
tube?: number;
|
|
40
40
|
size?: number;
|
|
41
41
|
text?: string;
|
|
42
|
+
/** text: packed outline font id, extra letter advance (em), bevel on/off */
|
|
43
|
+
font?: string;
|
|
44
|
+
letterSpacing?: number;
|
|
45
|
+
bevelEnabled?: boolean;
|
|
42
46
|
vertices?: number[];
|
|
43
47
|
indices?: number[];
|
|
44
48
|
normals?: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/utils/shapes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAyQ,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../src/utils/shapes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAyQ,MAAM,OAAO,CAAC;AAG3T,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG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AAC;AAgBpE;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE,cAAc,CAua7D,CAAC"}
|
package/dist/utils/shapes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoxGeometry, BufferGeometry, CapsuleGeometry, ConeGeometry, CylinderGeometry, DodecahedronGeometry, ExtrudeGeometry, Float32BufferAttribute, IcosahedronGeometry, OctahedronGeometry, Path, PlaneGeometry, RingGeometry, Shape, ShapeGeometry, SphereGeometry, TetrahedronGeometry, TorusGeometry, } from 'three';
|
|
2
2
|
import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
3
|
+
import { buildTextGeometry, outlineFontSync } from './textShape.js';
|
|
3
4
|
const safeNumber = (value, fallback, min) => {
|
|
4
5
|
const num = typeof value === 'number' && !Number.isNaN(value) ? value : fallback;
|
|
5
6
|
return min !== undefined ? Math.max(num, min) : num;
|
|
@@ -175,7 +176,9 @@ export const shapeGenerators = {
|
|
|
175
176
|
octahedron: ({ radius, detail }) => new OctahedronGeometry(safeNumber(radius, 0.5, 0.0001), safeNumber(detail, 0, 0)),
|
|
176
177
|
tetrahedron: ({ radius, detail }) => new TetrahedronGeometry(safeNumber(radius, 0.5, 0.0001), safeNumber(detail, 0, 0)),
|
|
177
178
|
dodecahedron: ({ radius, detail }) => new DodecahedronGeometry(safeNumber(radius, 0.5, 0.0001), safeNumber(detail, 0, 0)),
|
|
178
|
-
|
|
179
|
+
// the string extruded from a packed outline font (utils/textShape); empty until the font has loaded,
|
|
180
|
+
// GeometryShape re-renders when it lands
|
|
181
|
+
text: (o) => { const f = outlineFontSync(o.font); return f ? buildTextGeometry(f, o) : new BufferGeometry(); },
|
|
179
182
|
point: ({ size }) => new SphereGeometry(safeNumber(size, 0.1, 0.0001), 16, 16),
|
|
180
183
|
custom: ({ vertices = [], indices = [], normals, uvs }) => {
|
|
181
184
|
const geometry = new BufferGeometry();
|
|
@@ -2,6 +2,13 @@ import * as THREE from 'three';
|
|
|
2
2
|
import type { TerrainConfig, TerrainQualityConfig } from '@3driseai/3drise-core';
|
|
3
3
|
import type { TerrainTextureState } from '../hooks/useTerrainTextures';
|
|
4
4
|
import type { CloudSunState } from '../hooks/useCloudSun';
|
|
5
|
+
/**
|
|
6
|
+
* The height field's own uniforms (terrainFormUniforms): landform, scale, octaves,
|
|
7
|
+
* warp, erosion, shaping. Shared by the terrain material and by every material that
|
|
8
|
+
* includes `terrainFieldOnly` to read the ground — the ocean, for its shoreline —
|
|
9
|
+
* so the two can never disagree about where the ground is.
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyTerrainFieldUniforms(material: THREE.ShaderMaterial, config: TerrainConfig): void;
|
|
5
12
|
export declare function applyTerrainUniforms(material: THREE.ShaderMaterial, config: TerrainConfig, quality: TerrainQualityConfig): void;
|
|
6
13
|
export default applyTerrainUniforms;
|
|
7
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terrainUniforms.d.ts","sourceRoot":"","sources":["../../src/utils/terrainUniforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAE9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAoD1D,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,oBAAoB,GAC9B,IAAI,
|
|
1
|
+
{"version":3,"file":"terrainUniforms.d.ts","sourceRoot":"","sources":["../../src/utils/terrainUniforms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAe,MAAM,uBAAuB,CAAC;AAE9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAoD1D;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAwBrG;AAED,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,oBAAoB,GAC9B,IAAI,CAqCN;AAED,eAAe,oBAAoB,CAAC;AAUpC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,mBAAmB,GACzB,IAAI,CAyDN;AAiCD,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CA4BlG;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAwC5F"}
|
|
@@ -45,9 +45,15 @@ function setColor(uniform, hex) {
|
|
|
45
45
|
return;
|
|
46
46
|
uniform.value.setStyle(hex, THREE.SRGBColorSpace);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The height field's own uniforms (terrainFormUniforms): landform, scale, octaves,
|
|
50
|
+
* warp, erosion, shaping. Shared by the terrain material and by every material that
|
|
51
|
+
* includes `terrainFieldOnly` to read the ground — the ocean, for its shoreline —
|
|
52
|
+
* so the two can never disagree about where the ground is.
|
|
53
|
+
*/
|
|
54
|
+
export function applyTerrainFieldUniforms(material, config) {
|
|
49
55
|
const u = material.uniforms;
|
|
50
|
-
if (!u)
|
|
56
|
+
if (!u || !u.u_terrainType)
|
|
51
57
|
return;
|
|
52
58
|
u.u_terrainType.value = TYPE_INDEX[config.terrainType] ?? 2;
|
|
53
59
|
u.u_elevation.value = Math.max(config.elevation, 0.01);
|
|
@@ -68,6 +74,13 @@ export function applyTerrainUniforms(material, config, quality) {
|
|
|
68
74
|
u.u_plateau.value = config.plateau;
|
|
69
75
|
u.u_valleyDepth.value = config.valleyDepth;
|
|
70
76
|
u.u_valleyWidth.value = config.valleyWidth;
|
|
77
|
+
u.u_shadowSoftness.value = config.shadowSoftness;
|
|
78
|
+
}
|
|
79
|
+
export function applyTerrainUniforms(material, config, quality) {
|
|
80
|
+
const u = material.uniforms;
|
|
81
|
+
if (!u)
|
|
82
|
+
return;
|
|
83
|
+
applyTerrainFieldUniforms(material, config);
|
|
71
84
|
setColor(u.u_lowColor, config.lowColor);
|
|
72
85
|
setColor(u.u_midColor, config.midColor);
|
|
73
86
|
setColor(u.u_rockColor, config.rockColor);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
|
+
export declare const DEFAULT_TEXT_SHAPE_FONT = "inter";
|
|
3
|
+
export declare const isOutlineFontLoaded: (id: string | undefined) => boolean;
|
|
4
|
+
/** The packed outline font when it is already loaded, else null (and the load is started). */
|
|
5
|
+
export declare function outlineFontSync(id: string | undefined): any | null;
|
|
6
|
+
/** Loads (once) and caches a packed outline font. */
|
|
7
|
+
export declare function loadOutlineFont(id: string | undefined): Promise<any>;
|
|
8
|
+
export interface TextShapeOptions {
|
|
9
|
+
text?: string;
|
|
10
|
+
font?: string;
|
|
11
|
+
/** Em size in world units. */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** Extrusion depth in world units. */
|
|
14
|
+
height?: number;
|
|
15
|
+
/** Extra advance between letters, in em. */
|
|
16
|
+
letterSpacing?: number;
|
|
17
|
+
bevelEnabled?: boolean;
|
|
18
|
+
bevelThickness?: number;
|
|
19
|
+
bevelSize?: number;
|
|
20
|
+
bevelSegments?: number;
|
|
21
|
+
}
|
|
22
|
+
/** The string as an extruded, centred geometry. `font` is a loaded packed outline font (outlineFontSync / loadOutlineFont). */
|
|
23
|
+
export declare function buildTextGeometry(font: any, o: TextShapeOptions): BufferGeometry;
|
|
24
|
+
//# sourceMappingURL=textShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textShape.d.ts","sourceRoot":"","sources":["../../src/utils/textShape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgC,MAAM,OAAO,CAAC;AAgBrE,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAG/C,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,GAAG,SAAS,KAAG,OAAgC,CAAC;AAE9F,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAMlE;AAED,qDAAqD;AACrD,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAUpE;AAED,MAAM,WAAW,gBAAgB;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAqBD,+HAA+H;AAC/H,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAgChF"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { BufferGeometry, ExtrudeGeometry, Path, Shape } from 'three';
|
|
2
|
+
import { layoutOutline } from '../components/text/engine/glyphs.js';
|
|
3
|
+
import { loadOutline, TEXT_FONT_IDS } from '../components/text/fonts/index.js';
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Mesh text — the `text` shape of the mesh family: the string extruded into a solid, from the same packed
|
|
6
|
+
// outline fonts the text looks use (components/text/fonts), so one font list serves every text in 3drise.
|
|
7
|
+
//
|
|
8
|
+
// The outline fonts load lazily (one import() per font, a few hundred KB each). Shape generators are
|
|
9
|
+
// synchronous, so a font is read from this cache; the first build of a font yields an empty geometry and
|
|
10
|
+
// starts the load, and GeometryShape re-renders once it lands (useTextShapeFont).
|
|
11
|
+
// =============================================================================
|
|
12
|
+
const fonts = new Map();
|
|
13
|
+
const pending = new Map();
|
|
14
|
+
export const DEFAULT_TEXT_SHAPE_FONT = 'inter';
|
|
15
|
+
const fontId = (id) => (id && TEXT_FONT_IDS.includes(id) ? id : DEFAULT_TEXT_SHAPE_FONT);
|
|
16
|
+
export const isOutlineFontLoaded = (id) => fonts.has(fontId(id));
|
|
17
|
+
/** The packed outline font when it is already loaded, else null (and the load is started). */
|
|
18
|
+
export function outlineFontSync(id) {
|
|
19
|
+
const k = fontId(id);
|
|
20
|
+
const f = fonts.get(k);
|
|
21
|
+
if (f)
|
|
22
|
+
return f;
|
|
23
|
+
void loadOutlineFont(k);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/** Loads (once) and caches a packed outline font. */
|
|
27
|
+
export function loadOutlineFont(id) {
|
|
28
|
+
const k = fontId(id);
|
|
29
|
+
const f = fonts.get(k);
|
|
30
|
+
if (f)
|
|
31
|
+
return Promise.resolve(f);
|
|
32
|
+
let p = pending.get(k);
|
|
33
|
+
if (!p) {
|
|
34
|
+
p = loadOutline(k).then((font) => { fonts.set(k, font); pending.delete(k); return font; });
|
|
35
|
+
pending.set(k, p);
|
|
36
|
+
}
|
|
37
|
+
return p;
|
|
38
|
+
}
|
|
39
|
+
// even-odd point in polygon (flat [x, y, ...] array)
|
|
40
|
+
function inside(px, py, p) {
|
|
41
|
+
let c = false;
|
|
42
|
+
const n = p.length / 2;
|
|
43
|
+
for (let i = 0, j = n - 1; i < n; j = i++) {
|
|
44
|
+
const xi = p[2 * i], yi = p[2 * i + 1], xj = p[2 * j], yj = p[2 * j + 1];
|
|
45
|
+
if (((yi > py) !== (yj > py)) && (px < ((xj - xi) * (py - yi)) / (yj - yi) + xi))
|
|
46
|
+
c = !c;
|
|
47
|
+
}
|
|
48
|
+
return c;
|
|
49
|
+
}
|
|
50
|
+
const pathOf = (pts, P, s) => {
|
|
51
|
+
// layoutOutline closes every contour by repeating its first point: drop it, Shape closes itself
|
|
52
|
+
const n = pts.length / 2 - 1;
|
|
53
|
+
P.moveTo(pts[0] * s, pts[1] * s);
|
|
54
|
+
for (let i = 1; i < n; i++)
|
|
55
|
+
P.lineTo(pts[2 * i] * s, pts[2 * i + 1] * s);
|
|
56
|
+
P.closePath();
|
|
57
|
+
return P;
|
|
58
|
+
};
|
|
59
|
+
/** The string as an extruded, centred geometry. `font` is a loaded packed outline font (outlineFontSync / loadOutlineFont). */
|
|
60
|
+
export function buildTextGeometry(font, o) {
|
|
61
|
+
const size = Math.max(1e-4, o.size ?? 1), depth = Math.max(1e-4, o.height ?? 0.2);
|
|
62
|
+
const text = String(o.text ?? 'Hello');
|
|
63
|
+
const layout = layoutOutline(font, text.length ? text : ' ', { align: 'center', letterSpacing: o.letterSpacing ?? 0 });
|
|
64
|
+
const shapes = [];
|
|
65
|
+
// contours come per glyph, outer first then counters (layoutOutline sorts them so); a counter belongs to the
|
|
66
|
+
// outer contour of its glyph that contains it
|
|
67
|
+
const byGlyph = new Map();
|
|
68
|
+
for (const s of layout.strokes) {
|
|
69
|
+
let g = byGlyph.get(s.glyph);
|
|
70
|
+
if (!g) {
|
|
71
|
+
g = { outers: [], holes: [] };
|
|
72
|
+
byGlyph.set(s.glyph, g);
|
|
73
|
+
}
|
|
74
|
+
if (s.hole)
|
|
75
|
+
g.holes.push(s.pts);
|
|
76
|
+
else {
|
|
77
|
+
const shape = pathOf(s.pts, new Shape(), size);
|
|
78
|
+
g.outers.push({ pts: s.pts, shape });
|
|
79
|
+
shapes.push(shape);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
for (const g of byGlyph.values()) {
|
|
83
|
+
if (!g.outers.length)
|
|
84
|
+
continue;
|
|
85
|
+
for (const h of g.holes) {
|
|
86
|
+
const owner = g.outers.find((oc) => inside(h[0], h[1], oc.pts.subarray(0, oc.pts.length - 2))) ?? g.outers[0];
|
|
87
|
+
owner.shape.holes.push(pathOf(h, new Path(), size));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!shapes.length)
|
|
91
|
+
return new BufferGeometry();
|
|
92
|
+
const bevel = !!o.bevelEnabled;
|
|
93
|
+
const geo = new ExtrudeGeometry(shapes, {
|
|
94
|
+
depth, curveSegments: 1, bevelEnabled: bevel,
|
|
95
|
+
bevelThickness: bevel ? Math.max(0, o.bevelThickness ?? 0.03) : 0,
|
|
96
|
+
bevelSize: bevel ? Math.max(0, o.bevelSize ?? 0.02) : 0,
|
|
97
|
+
bevelOffset: 0,
|
|
98
|
+
bevelSegments: bevel ? Math.max(1, Math.round(o.bevelSegments ?? 3)) : 1,
|
|
99
|
+
});
|
|
100
|
+
geo.center();
|
|
101
|
+
return geo;
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3driseai/3drise-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@3driseai/3drise-common": "^1.0.1",
|
|
42
|
-
"@3driseai/3drise-core": "^1.0.
|
|
42
|
+
"@3driseai/3drise-core": "^1.0.24"
|
|
43
43
|
}
|
|
44
44
|
}
|