u-space 0.0.12 → 0.0.13
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/u-manager/index.cjs +15 -15
- package/dist/plugins/u-manager/index.js +91 -41
- package/dist/plugins/u-manager/semantics/FloorMesh.d.ts +3 -0
- package/dist/plugins/u-manager/semantics/types.d.ts +3 -1
- package/docs/api-plugin-u-manager.md +3 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileLoader, Scene, OrthographicCamera, Mesh, PlaneGeometry, MeshBasicNodeMaterial, SRGBColorSpace, Matrix4, Loader, LoadingManager, Group, EventDispatcher, Vector3, Box3, Quaternion, Sphere, Vector4, BufferGeometry, Float32BufferAttribute, DataTexture, RGBAFormat, FloatType, NearestFilter, Color, Euler } from "three/webgpu";
|
|
1
|
+
import { FileLoader, Scene, OrthographicCamera, Mesh, PlaneGeometry, MeshBasicNodeMaterial, SRGBColorSpace, Matrix4, Loader, LoadingManager, Group, EventDispatcher, Vector3, Box3, Quaternion, Sphere, Vector4, BufferGeometry, Float32BufferAttribute, DataTexture, RGBAFormat, FloatType, NearestFilter, MeshStandardNodeMaterial, Color, Euler } from "three/webgpu";
|
|
2
2
|
import { TextureLoaderManager, Model, ShapeMesh, CircleMesh, ExtrudeMesh, tweenAnimation, Topology, BaseMesh, BaseGroup, MaterialEffects as MaterialEffects$1 } from "u-space";
|
|
3
3
|
import { pass, attribute, vec4, positionLocal, textureLoad, ivec2, mat4, int, textureSize } from "three/tsl";
|
|
4
4
|
import { MaterialEffects } from "../../index.js";
|
|
@@ -20593,7 +20593,7 @@ class Watermarker extends Scene {
|
|
|
20593
20593
|
camera;
|
|
20594
20594
|
mesh;
|
|
20595
20595
|
overlayPass;
|
|
20596
|
-
#
|
|
20596
|
+
#r = !1;
|
|
20597
20597
|
#t = null;
|
|
20598
20598
|
constructor(t) {
|
|
20599
20599
|
super(), this.viewer = t, this.camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1), this.camera.position.z = 0.5, this.mesh = new Mesh(
|
|
@@ -20606,14 +20606,14 @@ class Watermarker extends Scene {
|
|
|
20606
20606
|
), this.add(this.mesh), this.overlayPass = pass(this, this.camera);
|
|
20607
20607
|
}
|
|
20608
20608
|
enable() {
|
|
20609
|
-
this.#
|
|
20610
|
-
this.#
|
|
20609
|
+
this.#r = !0, this.#i().then((t) => {
|
|
20610
|
+
this.#r && (this.mesh.material.map !== t && (this.mesh.material.map = t, this.mesh.material.needsUpdate = !0), this.viewer.renderPipeline.addOverlayPass(this.overlayPass));
|
|
20611
20611
|
}).catch((t) => {
|
|
20612
20612
|
this.#t = null, console.warn("u-space Watermarker: failed to load watermark texture.", t);
|
|
20613
20613
|
});
|
|
20614
20614
|
}
|
|
20615
20615
|
disable() {
|
|
20616
|
-
this.#
|
|
20616
|
+
this.#r = !1, this.viewer.renderPipeline.removeOverlayPass(this.overlayPass);
|
|
20617
20617
|
}
|
|
20618
20618
|
dispose() {
|
|
20619
20619
|
this.disable(), this.overlayPass.dispose(), this.mesh.geometry.dispose(), this.mesh.material.dispose(), this.mesh.material.map?.dispose();
|
|
@@ -20688,9 +20688,9 @@ class SceneLoader extends Loader {
|
|
|
20688
20688
|
cachedIds = /* @__PURE__ */ new Set();
|
|
20689
20689
|
_resourceData = null;
|
|
20690
20690
|
_treeData = [];
|
|
20691
|
-
#
|
|
20691
|
+
#r;
|
|
20692
20692
|
constructor(t) {
|
|
20693
|
-
super(), this.viewer = t, this.#
|
|
20693
|
+
super(), this.viewer = t, this.#r = new Watermarker(t), this.manager = new LoadingManager();
|
|
20694
20694
|
}
|
|
20695
20695
|
setKey(t) {
|
|
20696
20696
|
return this.key = t, this;
|
|
@@ -20708,7 +20708,7 @@ class SceneLoader extends Loader {
|
|
|
20708
20708
|
if (this._resourceData = o, d)
|
|
20709
20709
|
if (h.encryptWith === "DEBUG")
|
|
20710
20710
|
try {
|
|
20711
|
-
this._treeData = decryptWithDebugKey(o), this.#
|
|
20711
|
+
this._treeData = decryptWithDebugKey(o), this.#r.enable();
|
|
20712
20712
|
} catch {
|
|
20713
20713
|
throw new Error("u-space SceneLoader: decrypt with debug key failed");
|
|
20714
20714
|
}
|
|
@@ -20743,7 +20743,7 @@ class SceneLoader extends Loader {
|
|
|
20743
20743
|
}), this.cachedIds.clear();
|
|
20744
20744
|
}
|
|
20745
20745
|
dispose() {
|
|
20746
|
-
this.clearCache(), this.#
|
|
20746
|
+
this.clearCache(), this.#r.dispose();
|
|
20747
20747
|
}
|
|
20748
20748
|
}
|
|
20749
20749
|
class AnimationsLoader extends Loader {
|
|
@@ -20926,7 +20926,7 @@ function createSemanticMaterial(u, t, h) {
|
|
|
20926
20926
|
textureLoad(h, ivec2(l.add(2), v)),
|
|
20927
20927
|
textureLoad(h, ivec2(l.add(3), v))
|
|
20928
20928
|
);
|
|
20929
|
-
}, f = r(u), a = r(t).x, n = new
|
|
20929
|
+
}, f = r(u), a = r(t).x, n = new MeshStandardNodeMaterial({
|
|
20930
20930
|
transparent: !0,
|
|
20931
20931
|
depthWrite: !1
|
|
20932
20932
|
});
|
|
@@ -20964,6 +20964,7 @@ function buildMergedSemanticGeometry(u) {
|
|
|
20964
20964
|
c.push({
|
|
20965
20965
|
id: a.id,
|
|
20966
20966
|
kind: a.kind,
|
|
20967
|
+
name: a.name,
|
|
20967
20968
|
index: n,
|
|
20968
20969
|
baseMatrix: U,
|
|
20969
20970
|
matrix: new Matrix4(),
|
|
@@ -20984,17 +20985,19 @@ class FloorMesh extends BaseMesh {
|
|
|
20984
20985
|
wallsInstances = /* @__PURE__ */ new Map();
|
|
20985
20986
|
columnsInstances = /* @__PURE__ */ new Map();
|
|
20986
20987
|
spacesInstances = /* @__PURE__ */ new Map();
|
|
20988
|
+
doorsInstances = /* @__PURE__ */ new Map();
|
|
20989
|
+
windowsInstances = /* @__PURE__ */ new Map();
|
|
20987
20990
|
semanticInstances = /* @__PURE__ */ new Map();
|
|
20988
|
-
#
|
|
20991
|
+
#r;
|
|
20989
20992
|
#t;
|
|
20990
20993
|
#i;
|
|
20991
20994
|
#a;
|
|
20992
20995
|
#n;
|
|
20993
20996
|
constructor(t) {
|
|
20994
20997
|
const { geometry: h, states: o } = buildMergedSemanticGeometry(t), d = getStateTextureSize(o.length), r = getMatrixTextureSize(o.length), c = createStateTexture(d), f = createStateTexture(d), a = createStateTexture(r), n = createSemanticMaterial(c, f, a);
|
|
20995
|
-
super(h, n), this.#
|
|
20996
|
-
this.semanticInstances.set(e.id, e.index), e.kind === "WALL" && this.wallsInstances.set(e.id, e.index), e.kind === "COLUMN" && this.columnsInstances.set(e.id, e.index), e.kind === "SPACE" && this.spacesInstances.set(e.id, e.index), this.#o(e.index), this.#u(e.index), this.#s(e.index);
|
|
20997
|
-
}), this.userData.semanticEntries = this.#
|
|
20998
|
+
super(h, n), this.#r = o, this.#t = c, this.#i = f, this.#a = a, this.#n = new Mesh(), this.#n.matrixAutoUpdate = !1, this.frustumCulled = !1, this.#r.forEach((e) => {
|
|
20999
|
+
this.semanticInstances.set(e.id, e.index), e.kind === "WALL" && this.wallsInstances.set(e.id, e.index), e.kind === "COLUMN" && this.columnsInstances.set(e.id, e.index), e.kind === "SPACE" && this.spacesInstances.set(e.id, e.index), e.kind === "Doors" && this.doorsInstances.set(e.id, e.index), e.kind === "Windows" && this.windowsInstances.set(e.id, e.index), this.#o(e.index), this.#u(e.index), this.#s(e.index);
|
|
21000
|
+
}), this.userData.semanticEntries = this.#r.map(({ id: e, kind: s, name: l, index: v }) => ({ id: e, kind: s, name: l, index: v }));
|
|
20998
21001
|
}
|
|
20999
21002
|
planish() {
|
|
21000
21003
|
this.scale.set(1, 0.01, 1);
|
|
@@ -21003,7 +21006,7 @@ class FloorMesh extends BaseMesh {
|
|
|
21003
21006
|
this.scale.set(1, 1, 1);
|
|
21004
21007
|
}
|
|
21005
21008
|
get semanticCount() {
|
|
21006
|
-
return this.#
|
|
21009
|
+
return this.#r.length;
|
|
21007
21010
|
}
|
|
21008
21011
|
get instanceCount() {
|
|
21009
21012
|
return this.semanticCount;
|
|
@@ -21012,85 +21015,89 @@ class FloorMesh extends BaseMesh {
|
|
|
21012
21015
|
return this.semanticInstances.get(t);
|
|
21013
21016
|
}
|
|
21014
21017
|
getSemanticIdAt(t) {
|
|
21015
|
-
return this.#
|
|
21018
|
+
return this.#e(t).id;
|
|
21016
21019
|
}
|
|
21017
21020
|
getSemanticKindAt(t) {
|
|
21018
|
-
return this.#
|
|
21021
|
+
return this.#e(t).kind;
|
|
21022
|
+
}
|
|
21023
|
+
getSemanticNameAt(t) {
|
|
21024
|
+
return this.#e(t).name;
|
|
21019
21025
|
}
|
|
21020
21026
|
setColorAt(t, h) {
|
|
21021
|
-
const o = this.#
|
|
21027
|
+
const o = this.#e(t);
|
|
21022
21028
|
return copySemanticColor(h, o.color), this.#o(t), this;
|
|
21023
21029
|
}
|
|
21024
21030
|
getColorAt(t, h = new Vector4()) {
|
|
21025
|
-
const o = this.#
|
|
21031
|
+
const o = this.#e(t).color;
|
|
21026
21032
|
return h.copy(o), h;
|
|
21027
21033
|
}
|
|
21028
21034
|
setOpacityAt(t, h) {
|
|
21029
|
-
const o = this.#
|
|
21035
|
+
const o = this.#e(t);
|
|
21030
21036
|
return o.color.w = Math.max(0, Math.min(1, h)), this.#o(t), this;
|
|
21031
21037
|
}
|
|
21032
21038
|
getOpacityAt(t) {
|
|
21033
|
-
return this.#
|
|
21039
|
+
return this.#e(t).color.w;
|
|
21034
21040
|
}
|
|
21035
21041
|
setVisibleAt(t, h) {
|
|
21036
|
-
const o = this.#
|
|
21042
|
+
const o = this.#e(t);
|
|
21037
21043
|
return o.visible = h, this.#u(t), this;
|
|
21038
21044
|
}
|
|
21039
21045
|
getVisibleAt(t) {
|
|
21040
|
-
return this.#
|
|
21046
|
+
return this.#e(t).visible;
|
|
21041
21047
|
}
|
|
21042
21048
|
setMatrixAt(t, h) {
|
|
21043
|
-
const o = this.#
|
|
21049
|
+
const o = this.#e(t);
|
|
21044
21050
|
return o.matrix.copy(h), o.finalMatrix.multiplyMatrices(o.baseMatrix, o.matrix), this.#f(), this.#s(t), this;
|
|
21045
21051
|
}
|
|
21046
21052
|
setScaleAt(t, h, o, d) {
|
|
21047
|
-
const r = this.#
|
|
21053
|
+
const r = this.#e(t);
|
|
21048
21054
|
return r.matrix.decompose(_dummyPosition, _dummyQuaternion, _dummyScale), h instanceof Vector3 ? _dummyScale.copy(h) : _dummyScale.set(h, o ?? h, d ?? h), r.matrix.compose(_dummyPosition, _dummyQuaternion, _dummyScale), r.finalMatrix.multiplyMatrices(r.baseMatrix, r.matrix), this.#f(), this.#s(t), this;
|
|
21049
21055
|
}
|
|
21050
21056
|
getMatrixAt(t, h = new Matrix4()) {
|
|
21051
|
-
return h.copy(this.#
|
|
21057
|
+
return h.copy(this.#e(t).matrix), h;
|
|
21052
21058
|
}
|
|
21053
21059
|
getFinalMatrixAt(t, h = new Matrix4()) {
|
|
21054
|
-
return h.copy(this.#
|
|
21060
|
+
return h.copy(this.#e(t).finalMatrix), h;
|
|
21055
21061
|
}
|
|
21056
21062
|
computeBoundingBox() {
|
|
21057
21063
|
this.boundingBox === null && (this.boundingBox = new Box3()), this.boundingBox.makeEmpty();
|
|
21058
|
-
for (const t of this.#
|
|
21064
|
+
for (const t of this.#r)
|
|
21059
21065
|
this.getBoundingBoxAt(t.index, _box, !1) && this.boundingBox.union(_box);
|
|
21060
21066
|
}
|
|
21061
21067
|
computeBoundingSphere() {
|
|
21062
21068
|
this.boundingSphere === null && (this.boundingSphere = new Sphere()), this.boundingSphere.makeEmpty();
|
|
21063
|
-
for (const t of this.#
|
|
21069
|
+
for (const t of this.#r)
|
|
21064
21070
|
this.getBoundingSphereAt(t.index, _boundsSphere, !1) && this.boundingSphere.union(_boundsSphere);
|
|
21065
21071
|
}
|
|
21066
21072
|
getBoundingBoxAt(t, h = new Box3(), o = !0) {
|
|
21067
|
-
const d = this.#
|
|
21073
|
+
const d = this.#e(t);
|
|
21068
21074
|
return d.geometry.boundingBox || d.geometry.computeBoundingBox(), d.geometry.boundingBox ? (h.copy(d.geometry.boundingBox).applyMatrix4(d.finalMatrix), o && (this.updateWorldMatrix(!0, !1), h.applyMatrix4(this.matrixWorld)), h) : null;
|
|
21069
21075
|
}
|
|
21070
21076
|
getBoundingSphereAt(t, h = new Sphere(), o = !0) {
|
|
21071
|
-
const d = this.#
|
|
21077
|
+
const d = this.#e(t);
|
|
21072
21078
|
return d.geometry.boundingSphere || d.geometry.computeBoundingSphere(), d.geometry.boundingSphere ? (h.copy(d.geometry.boundingSphere), o ? (this.updateWorldMatrix(!0, !1), _boundsMatrix.multiplyMatrices(this.matrixWorld, d.finalMatrix), h.applyMatrix4(_boundsMatrix)) : h.applyMatrix4(d.finalMatrix), h) : null;
|
|
21073
21079
|
}
|
|
21074
21080
|
raycast(t, h) {
|
|
21075
21081
|
if (this.visible === !1 && this.ignoreInvisibleWhenRaycast === !0)
|
|
21076
21082
|
return !1;
|
|
21077
21083
|
this.updateWorldMatrix(!0, !1), this.#n.material = this.material;
|
|
21078
|
-
for (const o of this.#
|
|
21084
|
+
for (const o of this.#r)
|
|
21079
21085
|
if (!(!o.visible || o.color.w <= 1e-3)) {
|
|
21080
21086
|
this.#n.geometry = o.geometry, this.#n.matrixWorld.multiplyMatrices(this.matrixWorld, o.finalMatrix), _raycastHits.length = 0, this.#n.raycast(t, _raycastHits);
|
|
21081
21087
|
for (const d of _raycastHits)
|
|
21082
21088
|
d.object = this, d.instanceId = o.index, Object.assign(d, {
|
|
21083
21089
|
semanticId: o.id,
|
|
21084
21090
|
semanticKind: o.kind,
|
|
21091
|
+
semanticName: o.name,
|
|
21085
21092
|
semanticIndex: o.index
|
|
21086
21093
|
}), h.push(d);
|
|
21087
21094
|
}
|
|
21088
21095
|
}
|
|
21089
21096
|
dispose() {
|
|
21090
|
-
this.geometry.dispose(), Array.isArray(this.material) ? this.material.forEach((t) => t.dispose()) : this.material.dispose(), this.#t.dispose(), this.#i.dispose(), this.#a.dispose(), this.#
|
|
21097
|
+
this.geometry.dispose(), Array.isArray(this.material) ? this.material.forEach((t) => t.dispose()) : this.material.dispose(), this.#t.dispose(), this.#i.dispose(), this.#a.dispose(), this.#r.forEach((t) => t.geometry.dispose());
|
|
21091
21098
|
}
|
|
21092
|
-
#
|
|
21093
|
-
const h = this.#
|
|
21099
|
+
#e(t) {
|
|
21100
|
+
const h = this.#r[t];
|
|
21094
21101
|
if (!h)
|
|
21095
21102
|
throw new Error(`u-space FloorMesh: invalid semantic index ${t}.`);
|
|
21096
21103
|
return h;
|
|
@@ -21099,14 +21106,14 @@ class FloorMesh extends BaseMesh {
|
|
|
21099
21106
|
this.boundingBox = null, this.boundingSphere = null;
|
|
21100
21107
|
}
|
|
21101
21108
|
#o(t) {
|
|
21102
|
-
this.#
|
|
21109
|
+
this.#e(t).color.toArray(this.#t.image.data, t * 4), this.#t.needsUpdate = !0;
|
|
21103
21110
|
}
|
|
21104
21111
|
#u(t) {
|
|
21105
|
-
const h = this.#
|
|
21112
|
+
const h = this.#e(t), o = this.#i.image.data;
|
|
21106
21113
|
o[t * 4] = h.visible ? 1 : 0, o[t * 4 + 1] = 0, o[t * 4 + 2] = 0, o[t * 4 + 3] = 1, this.#i.needsUpdate = !0;
|
|
21107
21114
|
}
|
|
21108
21115
|
#s(t) {
|
|
21109
|
-
this.#
|
|
21116
|
+
this.#e(t).finalMatrix.toArray(this.#a.image.data, t * 16), this.#a.needsUpdate = !0;
|
|
21110
21117
|
}
|
|
21111
21118
|
}
|
|
21112
21119
|
class BuildingGroup extends BaseGroup {
|
|
@@ -21146,6 +21153,16 @@ class BuildingGroup extends BaseGroup {
|
|
|
21146
21153
|
return this.floorMeshes.forEach((t) => t.unplanish()), this;
|
|
21147
21154
|
}
|
|
21148
21155
|
}
|
|
21156
|
+
const SEMANTIC_INITIAL_COLORS = {
|
|
21157
|
+
WALL: new Vector4(0.86, 0.86, 0.82, 1),
|
|
21158
|
+
COLUMN: new Vector4(0.62, 0.65, 0.68, 1),
|
|
21159
|
+
SPACE: new Vector4(0.36, 0.7, 0.5, 0.45),
|
|
21160
|
+
Doors: new Vector4(0.9, 0.52, 0.2, 1),
|
|
21161
|
+
Windows: new Vector4(0.28, 0.62, 0.95, 0.65)
|
|
21162
|
+
};
|
|
21163
|
+
function getInitialColor(u) {
|
|
21164
|
+
return SEMANTIC_INITIAL_COLORS[u].clone();
|
|
21165
|
+
}
|
|
21149
21166
|
function getValidPolygonShape(u, t, h) {
|
|
21150
21167
|
return !Array.isArray(u) || u.length < 4 || u.length % 2 !== 0 ? (console.warn(`u-space SemanticLoader: invalid ${t} polygon shape for id ${h}.`), null) : u;
|
|
21151
21168
|
}
|
|
@@ -21178,7 +21195,7 @@ class SemanticParser {
|
|
|
21178
21195
|
id: e.ID,
|
|
21179
21196
|
kind: "WALL",
|
|
21180
21197
|
geometry: l,
|
|
21181
|
-
color:
|
|
21198
|
+
color: getInitialColor("WALL")
|
|
21182
21199
|
});
|
|
21183
21200
|
}), c.Columns?.forEach((n) => {
|
|
21184
21201
|
const e = t.Columns?.[n];
|
|
@@ -21194,7 +21211,39 @@ class SemanticParser {
|
|
|
21194
21211
|
id: e.ID,
|
|
21195
21212
|
kind: "COLUMN",
|
|
21196
21213
|
geometry: l,
|
|
21197
|
-
color:
|
|
21214
|
+
color: getInitialColor("COLUMN")
|
|
21215
|
+
});
|
|
21216
|
+
}), c.Doors?.forEach((n) => {
|
|
21217
|
+
const e = t.Doors?.[n];
|
|
21218
|
+
if (!e || !e.Polygon) return;
|
|
21219
|
+
const s = getValidPolygonShape(e.Polygon.shape, "Doors", e.ID);
|
|
21220
|
+
if (!s) return;
|
|
21221
|
+
const l = ExtrudeMesh.createFromPoints(convertToPlaneIVector2(s), {
|
|
21222
|
+
geometryParameters: {
|
|
21223
|
+
options: { depth: e.Height, bevelEnabled: !1 }
|
|
21224
|
+
}
|
|
21225
|
+
}).geometry;
|
|
21226
|
+
l.translate(0, e.Elevation, 0), l.userData.id = e.ID, f.push({
|
|
21227
|
+
id: e.ID,
|
|
21228
|
+
kind: "Doors",
|
|
21229
|
+
geometry: l,
|
|
21230
|
+
color: getInitialColor("Doors")
|
|
21231
|
+
});
|
|
21232
|
+
}), c.Windows?.forEach((n) => {
|
|
21233
|
+
const e = t.Windows?.[n];
|
|
21234
|
+
if (!e || !e.Polygon) return;
|
|
21235
|
+
const s = getValidPolygonShape(e.Polygon.shape, "Windows", e.ID);
|
|
21236
|
+
if (!s) return;
|
|
21237
|
+
const l = ExtrudeMesh.createFromPoints(convertToPlaneIVector2(s), {
|
|
21238
|
+
geometryParameters: {
|
|
21239
|
+
options: { depth: e.Height, bevelEnabled: !1 }
|
|
21240
|
+
}
|
|
21241
|
+
}).geometry;
|
|
21242
|
+
l.translate(0, e.Elevation, 0), l.userData.id = e.ID, f.push({
|
|
21243
|
+
id: e.ID,
|
|
21244
|
+
kind: "Windows",
|
|
21245
|
+
geometry: l,
|
|
21246
|
+
color: getInitialColor("Windows")
|
|
21198
21247
|
});
|
|
21199
21248
|
}), c.Spaces?.forEach((n) => {
|
|
21200
21249
|
const e = t.Spaces?.[n];
|
|
@@ -21209,8 +21258,9 @@ class SemanticParser {
|
|
|
21209
21258
|
v.translate(0, e.GroundHeight, 0), v.userData.id = e.ID, f.push({
|
|
21210
21259
|
id: e.ID,
|
|
21211
21260
|
kind: "SPACE",
|
|
21261
|
+
name: e.Name,
|
|
21212
21262
|
geometry: v,
|
|
21213
|
-
color:
|
|
21263
|
+
color: getInitialColor("SPACE")
|
|
21214
21264
|
});
|
|
21215
21265
|
}), f.length === 0) return;
|
|
21216
21266
|
const a = new FloorMesh(f);
|
|
@@ -10,6 +10,8 @@ export declare class FloorMesh extends BaseMesh {
|
|
|
10
10
|
wallsInstances: Map<string, number>;
|
|
11
11
|
columnsInstances: Map<string, number>;
|
|
12
12
|
spacesInstances: Map<string, number>;
|
|
13
|
+
doorsInstances: Map<string, number>;
|
|
14
|
+
windowsInstances: Map<string, number>;
|
|
13
15
|
semanticInstances: Map<string, number>;
|
|
14
16
|
constructor(entries: SemanticGeometryEntry[]);
|
|
15
17
|
planish(): void;
|
|
@@ -19,6 +21,7 @@ export declare class FloorMesh extends BaseMesh {
|
|
|
19
21
|
getSemanticIndexById(id: string): number | undefined;
|
|
20
22
|
getSemanticIdAt(index: number): string;
|
|
21
23
|
getSemanticKindAt(index: number): import("./types").SemanticKind;
|
|
24
|
+
getSemanticNameAt(index: number): string | undefined;
|
|
22
25
|
setColorAt(index: number, color: SemanticColor): this;
|
|
23
26
|
getColorAt(index: number, target?: Vector4): Vector4;
|
|
24
27
|
setOpacityAt(index: number, opacity: number): this;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { BufferGeometry, Color, Matrix4, Vector3, Vector4 } from 'three/webgpu';
|
|
2
|
-
export type SemanticKind = 'WALL' | 'COLUMN' | 'SPACE';
|
|
2
|
+
export type SemanticKind = 'WALL' | 'COLUMN' | 'SPACE' | 'Doors' | 'Windows';
|
|
3
3
|
export type SemanticColor = Color | Vector3 | Vector4;
|
|
4
4
|
export interface SemanticGeometryEntry {
|
|
5
5
|
id: string;
|
|
6
6
|
kind: SemanticKind;
|
|
7
|
+
name?: string;
|
|
7
8
|
geometry: BufferGeometry;
|
|
8
9
|
color: Vector4;
|
|
9
10
|
}
|
|
10
11
|
export interface SemanticObjectState {
|
|
11
12
|
id: string;
|
|
12
13
|
kind: SemanticKind;
|
|
14
|
+
name?: string;
|
|
13
15
|
index: number;
|
|
14
16
|
baseMatrix: Matrix4;
|
|
15
17
|
matrix: Matrix4;
|
|
@@ -59,10 +59,11 @@ floor.addEventListener('click', ({ event }) => {
|
|
|
59
59
|
| :---------- | :--- |
|
|
60
60
|
| `semanticCount` / `instanceCount` | 当前楼层语义实例数量。 |
|
|
61
61
|
| `semanticInstances` | `Map<string, number>`,从语义对象 ID 映射到实例下标。 |
|
|
62
|
-
| `wallsInstances` / `columnsInstances` / `spacesInstances` | 按语义类型维护的 ID 到实例下标映射。 |
|
|
62
|
+
| `wallsInstances` / `columnsInstances` / `spacesInstances` / `doorsInstances` / `windowsInstances` | 按语义类型维护的 ID 到实例下标映射。 |
|
|
63
63
|
| `getSemanticIndexById(id)` | 根据语义 ID 获取实例下标。 |
|
|
64
64
|
| `getSemanticIdAt(index)` | 获取实例语义 ID。 |
|
|
65
|
-
| `getSemanticKindAt(index)` | 获取实例类型:`'WALL' \| 'COLUMN' \| 'SPACE'`。 |
|
|
65
|
+
| `getSemanticKindAt(index)` | 获取实例类型:`'WALL' \| 'COLUMN' \| 'SPACE' \| 'Doors' \| 'Windows'`。 |
|
|
66
|
+
| `getSemanticNameAt(index)` | 获取实例名称;当前 `SPACE` 会从语义数据的 `Name` 写入,其他类型可能为 `undefined`。 |
|
|
66
67
|
| `setColorAt(index, color)` / `getColorAt(index, target?)` | 修改或读取实例颜色,支持 `Color`、`Vector3`、`Vector4`。 |
|
|
67
68
|
| `setOpacityAt(index, opacity)` / `getOpacityAt(index)` | 修改或读取实例透明度。 |
|
|
68
69
|
| `setVisibleAt(index, visible)` / `getVisibleAt(index)` | 修改或读取实例显隐状态。 |
|