@jfk-solutions/demo3d-file-format 1.6.0 → 1.8.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/README.md +78 -1
- package/dist/examples/export-embedded-viewer-standalone.html +193 -0
- package/dist/examples/three-render-smoke-standalone.html +4933 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +36 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +178 -11
- package/dist/model.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +135 -9
- package/dist/parser.js.map +1 -1
- package/dist/raw3d.d.ts +35 -4
- package/dist/raw3d.d.ts.map +1 -1
- package/dist/raw3d.js +63 -6
- package/dist/raw3d.js.map +1 -1
- package/dist/three/index.d.ts +4 -0
- package/dist/three/index.d.ts.map +1 -1
- package/dist/three/index.js +186 -21
- package/dist/three/index.js.map +1 -1
- package/dist/three/presentation.d.ts +31 -0
- package/dist/three/presentation.d.ts.map +1 -0
- package/dist/three/presentation.js +137 -0
- package/dist/three/presentation.js.map +1 -0
- package/dist/three/raw3d.d.ts +4 -0
- package/dist/three/raw3d.d.ts.map +1 -1
- package/dist/three/raw3d.js +202 -14
- package/dist/three/raw3d.js.map +1 -1
- package/dist/xml.d.ts +4 -1
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +14 -3
- package/dist/xml.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
Browser-first TypeScript parser and Three.js adapter for Demo3D/Emulate3D
|
|
4
4
|
`.demo3d` project files and render-ready `.raw3d` scene files.
|
|
5
5
|
|
|
6
|
-
The parser accepts an `ArrayBuffer`, `Uint8Array`, or `DataView`, reads the outer
|
|
6
|
+
The parser accepts an `ArrayBuffer`, `Uint8Array`, or `DataView`, reads the outer
|
|
7
|
+
ZIP package, extracts either the traditional nested XML model document or the
|
|
8
|
+
Demo3D 2026 `Model.xml`, and returns a lossless object structure with typed
|
|
9
|
+
helpers for the pieces most useful to rendering adapters. Demo3D 2026 external
|
|
10
|
+
geometry caches (`meshes/map.xml` with `v*.dat`, `i*.dat`, and `s*.dat`
|
|
11
|
+
buffers) are decoded automatically.
|
|
7
12
|
|
|
8
13
|
## Install
|
|
9
14
|
|
|
@@ -25,6 +30,12 @@ console.log(parsed.model.meshes.length);
|
|
|
25
30
|
console.log(parsed.model.visuals.length);
|
|
26
31
|
```
|
|
27
32
|
|
|
33
|
+
Saved project views are available through `parsed.model.views`; the name stored
|
|
34
|
+
in `parsed.model.defaultView` identifies the project's default view. Each view
|
|
35
|
+
contains its Demo3D `position` and `target` vectors. The included Three.js
|
|
36
|
+
viewer exposes these from its **Saved views** menu and opens the default view
|
|
37
|
+
automatically. RAW3D saved views are exposed as `parsed.model.views` as well.
|
|
38
|
+
|
|
28
39
|
RAW3D scenes use a separate, strongly typed API because their `Model.xml`, flat
|
|
29
40
|
node hierarchy, and external vertex/index buffers differ from the editable
|
|
30
41
|
Demo3D project schema:
|
|
@@ -66,6 +77,46 @@ npm run demo:three
|
|
|
66
77
|
|
|
67
78
|
Then open the printed `http://127.0.0.1:.../examples/three-render-smoke.html` URL and choose a `.demo3d` or `.raw3d` file.
|
|
68
79
|
|
|
80
|
+
To create a single-file version that can be opened directly from the file
|
|
81
|
+
system without a server, run:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm run build:test-page
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Open `dist/examples/three-render-smoke-standalone.html`. Three.js,
|
|
88
|
+
OrbitControls, and the Demo3D parser/renderer are bundled into that HTML file;
|
|
89
|
+
only the `.demo3d` or `.raw3d` file selected by the user remains external. The
|
|
90
|
+
normal `npm run build` command also generates this standalone page.
|
|
91
|
+
|
|
92
|
+
### Export an Embedded Viewer
|
|
93
|
+
|
|
94
|
+
To create a standalone HTML viewer with one model embedded inside it, run:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm run demo:export
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Open the printed URL, choose either a `.demo3d` or `.raw3d` file, and select
|
|
101
|
+
an export mode:
|
|
102
|
+
|
|
103
|
+
- **Generated Three.js objects and cameras (source-protected)** is the default.
|
|
104
|
+
It converts the
|
|
105
|
+
model first and creates `<model>-three-viewer.html` containing only serialized
|
|
106
|
+
Three.js objects, materials, geometry, textures, layer visibility, and
|
|
107
|
+
cameras. The original archive, `Model.xml`, and other Demo3D project data are
|
|
108
|
+
not included, so the source `.demo3d` file cannot be extracted from the
|
|
109
|
+
exported viewer. Rendered mesh data necessarily remains inspectable in any
|
|
110
|
+
browser-based viewer.
|
|
111
|
+
- **Original Demo3D/RAW3D file (lossless)** creates `<model>-viewer.html` with
|
|
112
|
+
the original file embedded.
|
|
113
|
+
|
|
114
|
+
Select **Download viewer HTML** after choosing the mode. The downloaded page can
|
|
115
|
+
be opened directly with `file://` and presents the model immediately without a
|
|
116
|
+
file-open control. The exporter itself is also available as
|
|
117
|
+
`dist/examples/export-embedded-viewer-standalone.html` and can be opened
|
|
118
|
+
directly from the file system.
|
|
119
|
+
|
|
69
120
|
The parser root remains independent of Three.js. Renderer features that require
|
|
70
121
|
procedural reconstruction are opt-in through the `demo3d-file-format/three`
|
|
71
122
|
subpath:
|
|
@@ -160,6 +211,31 @@ lights come from the same Three.js module as the renderer. Set
|
|
|
160
211
|
WebGPU can improve repeated rendering of complex scenes, but it does not speed
|
|
161
212
|
up archive/XML parsing and may have higher first-frame shader compilation cost.
|
|
162
213
|
|
|
214
|
+
### Enhanced Render Mode
|
|
215
|
+
|
|
216
|
+
For a more presentation-ready view, apply the optional enhanced preset after
|
|
217
|
+
adding the parsed group to a scene. It enables soft shadows, marks opaque model
|
|
218
|
+
meshes as shadow casters/receivers, adds fitted key and fill lighting, and puts
|
|
219
|
+
a matte contact floor below the model:
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import { applyDemo3DThreeRenderMode } from "demo3d-file-format/three";
|
|
223
|
+
|
|
224
|
+
const presentation = applyDemo3DThreeRenderMode({
|
|
225
|
+
three: selected.three,
|
|
226
|
+
renderer: selected.renderer,
|
|
227
|
+
scene,
|
|
228
|
+
object: group,
|
|
229
|
+
mode: "enhanced"
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Remove the preset and restore the previous renderer and mesh settings.
|
|
233
|
+
presentation.dispose();
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Use `mode: "standard"` for the lighter-weight lighting preset. The browser
|
|
237
|
+
smoke-test page includes a **Better render** switch for comparing both modes.
|
|
238
|
+
|
|
163
239
|
## Current Scope
|
|
164
240
|
|
|
165
241
|
- Read-only parser.
|
|
@@ -167,6 +243,7 @@ up archive/XML parsing and may have higher first-frame shader compilation cost.
|
|
|
167
243
|
- Stored and DEFLATE ZIP entries.
|
|
168
244
|
- Full XML tree preservation.
|
|
169
245
|
- Core typed classes for project header, visuals, meshes, materials, resources, and unknown typed entries.
|
|
246
|
+
- Demo3D 2026 `Model.xml`, flat visual hierarchies, and external mesh caches.
|
|
170
247
|
- Vendor-specific object types are preserved as `Demo3DUnknownObject` until explicit classes are added.
|
|
171
248
|
- RAW3D `Model.xml` scene metadata and external geometry/texture resources.
|
|
172
249
|
- RAW3D Three.js rendering with source geometry shared across scene nodes.
|