diff --git a/package.json b/package.json index 8bc24e3e4..4a6467808 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@types/three": "0.160.0", "@typescript-eslint/eslint-plugin": "^4.27.0", "@typescript-eslint/parser": "^4.27.0", - "bim-fragment": "1.5.0-alpha.2", + "bim-fragment": "1.5.0-alpha.3", "cpy-cli": "^3.1.1", "eslint": "^7.28.0", "eslint-config-airbnb-base": "^14.2.1", @@ -57,7 +57,7 @@ "unzipit": "^1.4.3" }, "peerDependencies": { - "bim-fragment": "1.5.0-alpha.2", + "bim-fragment": "1.5.0-alpha.3", "three": "^0.160.1", "web-ifc": "0.0.51" } diff --git a/resources/openbim-components.js b/resources/openbim-components.js index f9e4ed104..1348afdea 100644 --- a/resources/openbim-components.js +++ b/resources/openbim-components.js @@ -24400,8 +24400,12 @@ class Alignment { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } + initialPk() { + const offset = this.bb.__offset(this.bb_pos, 10); + return offset ? this.bb.readFloat32(this.bb_pos + offset) : 0.0; + } static startAlignment(builder) { - builder.startObject(3); + builder.startObject(4); } static addVertical(builder, verticalOffset) { builder.addFieldOffset(0, verticalOffset, 0); @@ -24442,19 +24446,102 @@ class Alignment { static startAbsoluteVector(builder, numElems) { builder.startVector(4, numElems, 4); } + static addInitialPk(builder, initialPk) { + builder.addFieldFloat32(3, initialPk, 0.0); + } static endAlignment(builder) { const offset = builder.endObject(); return offset; } - static createAlignment(builder, verticalOffset, horizontalOffset, absoluteOffset) { + static createAlignment(builder, verticalOffset, horizontalOffset, absoluteOffset, initialPk) { Alignment.startAlignment(builder); Alignment.addVertical(builder, verticalOffset); Alignment.addHorizontal(builder, horizontalOffset); Alignment.addAbsolute(builder, absoluteOffset); + Alignment.addInitialPk(builder, initialPk); return Alignment.endAlignment(builder); } } +// automatically generated by the FlatBuffers compiler, do not modify +class CivilData { + constructor() { + this.bb = null; + this.bb_pos = 0; + } + __init(i, bb) { + this.bb_pos = i; + this.bb = bb; + return this; + } + static getRootAsCivilData(bb, obj) { + return (obj || new CivilData()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + static getSizePrefixedRootAsCivilData(bb, obj) { + bb.setPosition(bb.position() + SIZE_PREFIX_LENGTH); + return (obj || new CivilData()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + } + alignments(index, obj) { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? (obj || new Alignment()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; + } + alignmentsLength() { + const offset = this.bb.__offset(this.bb_pos, 4); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + coordinationMatrix(index) { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.readFloat32(this.bb.__vector(this.bb_pos + offset) + index * 4) : 0; + } + coordinationMatrixLength() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + } + coordinationMatrixArray() { + const offset = this.bb.__offset(this.bb_pos, 6); + return offset ? new Float32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + offset), this.bb.__vector_len(this.bb_pos + offset)) : null; + } + static startCivilData(builder) { + builder.startObject(2); + } + static addAlignments(builder, alignmentsOffset) { + builder.addFieldOffset(0, alignmentsOffset, 0); + } + static createAlignmentsVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addOffset(data[i]); + } + return builder.endVector(); + } + static startAlignmentsVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static addCoordinationMatrix(builder, coordinationMatrixOffset) { + builder.addFieldOffset(1, coordinationMatrixOffset, 0); + } + static createCoordinationMatrixVector(builder, data) { + builder.startVector(4, data.length, 4); + for (let i = data.length - 1; i >= 0; i--) { + builder.addFloat32(data[i]); + } + return builder.endVector(); + } + static startCoordinationMatrixVector(builder, numElems) { + builder.startVector(4, numElems, 4); + } + static endCivilData(builder) { + const offset = builder.endObject(); + return offset; + } + static createCivilData(builder, alignmentsOffset, coordinationMatrixOffset) { + CivilData.startCivilData(builder); + CivilData.addAlignments(builder, alignmentsOffset); + CivilData.addCoordinationMatrix(builder, coordinationMatrixOffset); + return CivilData.endCivilData(builder); + } +} + // automatically generated by the FlatBuffers compiler, do not modify class Fragment { constructor() { @@ -24770,13 +24857,9 @@ let FragmentsGroup$1 = class FragmentsGroup { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } - civil(index, obj) { + civil(obj) { const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? (obj || new Alignment()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; - } - civilLength() { - const offset = this.bb.__offset(this.bb_pos, 6); - return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; + return offset ? (obj || new CivilData()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } coordinationMatrix(index) { const offset = this.bb.__offset(this.bb_pos, 8); @@ -24933,16 +25016,6 @@ let FragmentsGroup$1 = class FragmentsGroup { static addCivil(builder, civilOffset) { builder.addFieldOffset(1, civilOffset, 0); } - static createCivilVector(builder, data) { - builder.startVector(4, data.length, 4); - for (let i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); - } - static startCivilVector(builder, numElems) { - builder.startVector(4, numElems, 4); - } static addCoordinationMatrix(builder, coordinationMatrixOffset) { builder.addFieldOffset(2, coordinationMatrixOffset, 0); } @@ -25091,28 +25164,6 @@ let FragmentsGroup$1 = class FragmentsGroup { static finishSizePrefixedFragmentsGroupBuffer(builder, offset) { builder.finish(offset, undefined, true); } - static createFragmentsGroup(builder, itemsOffset, civilOffset, coordinationMatrixOffset, idsOffset, itemsKeysOffset, itemsKeysIndicesOffset, itemsRelsOffset, itemsRelsIndicesOffset, fragmentKeysOffset, idOffset, nameOffset, ifcNameOffset, ifcDescriptionOffset, ifcSchemaOffset, maxExpressId, boundingBoxOffset, opaqueGeometriesIdsOffset, transparentGeometriesIdsOffset) { - FragmentsGroup.startFragmentsGroup(builder); - FragmentsGroup.addItems(builder, itemsOffset); - FragmentsGroup.addCivil(builder, civilOffset); - FragmentsGroup.addCoordinationMatrix(builder, coordinationMatrixOffset); - FragmentsGroup.addIds(builder, idsOffset); - FragmentsGroup.addItemsKeys(builder, itemsKeysOffset); - FragmentsGroup.addItemsKeysIndices(builder, itemsKeysIndicesOffset); - FragmentsGroup.addItemsRels(builder, itemsRelsOffset); - FragmentsGroup.addItemsRelsIndices(builder, itemsRelsIndicesOffset); - FragmentsGroup.addFragmentKeys(builder, fragmentKeysOffset); - FragmentsGroup.addId(builder, idOffset); - FragmentsGroup.addName(builder, nameOffset); - FragmentsGroup.addIfcName(builder, ifcNameOffset); - FragmentsGroup.addIfcDescription(builder, ifcDescriptionOffset); - FragmentsGroup.addIfcSchema(builder, ifcSchemaOffset); - FragmentsGroup.addMaxExpressId(builder, maxExpressId); - FragmentsGroup.addBoundingBox(builder, boundingBoxOffset); - FragmentsGroup.addOpaqueGeometriesIds(builder, opaqueGeometriesIdsOffset); - FragmentsGroup.addTransparentGeometriesIds(builder, transparentGeometriesIdsOffset); - return FragmentsGroup.endFragmentsGroup(builder); - } }; /* unzipit@1.4.3, license MIT */ @@ -26379,11 +26430,13 @@ class Serializer { export(group) { const builder = new Builder(1024); const items = []; - const alignments = []; const G = FragmentsGroup$1; const F = Fragment; + let civilData = null; if (group.civilData) { + const alignments = []; const A = Alignment; + const C = CivilData; for (const [_id, alignment] of group.civilData.alignments) { const { absolute, horizontal, vertical } = alignment; const horCurves = this.saveCivilCurves(horizontal, builder); @@ -26396,9 +26449,16 @@ class Serializer { A.addHorizontal(builder, horVector); A.addVertical(builder, verVector); A.addAbsolute(builder, absVector); + A.addInitialPk(builder, alignment.initialKP); const exported = A.endAlignment(builder); alignments.push(exported); } + const algVector = C.createAlignmentsVector(builder, alignments); + const coordVector = C.createCoordinationMatrixVector(builder, group.coordinationMatrix.elements); + C.startCivilData(builder); + C.addAlignments(builder, algVector); + C.addCoordinationMatrix(builder, coordVector); + civilData = C.endCivilData(builder); } for (const fragment of group.items) { const result = fragment.exportData(); @@ -26489,10 +26549,6 @@ class Serializer { const { min, max } = group.boundingBox; const bbox = [min.x, min.y, min.z, max.x, max.y, max.z]; const bboxVector = G.createBoundingBoxVector(builder, bbox); - let alignVector = null; - if (alignments.length) { - alignVector = G.createCivilVector(builder, alignments); - } G.startFragmentsGroup(builder); G.addId(builder, groupID); G.addName(builder, groupName); @@ -26511,8 +26567,8 @@ class Serializer { G.addBoundingBox(builder, bboxVector); G.addOpaqueGeometriesIds(builder, oIdsVector); G.addTransparentGeometriesIds(builder, tIdsVector); - if (alignments.length && alignVector !== null) { - G.addCivil(builder, alignVector); + if (civilData !== null) { + G.addCivil(builder, civilData); } const result = FragmentsGroup$1.endFragmentsGroup(builder); builder.finish(result); @@ -26581,26 +26637,36 @@ class Serializer { } constructFragmentGroup(group) { const fragmentsGroup = new FragmentsGroup(); - const cLength = group.civilLength(); - for (let i = 0; i < cLength; i++) { - const lineMat = new THREE$1.LineBasicMaterial({ color: 0xffffff }); - const aligData = group.civil(i); - if (!aligData) { - throw new Error("Alignment not found!"); - } - const horLength = aligData.horizontalLength(); - const horizontal = this.constructCivilCurves(aligData, "horizontal", horLength, lineMat); - const verLength = aligData.verticalLength(); - const vertical = this.constructCivilCurves(aligData, "vertical", verLength, lineMat); - const absLength = aligData.horizontalLength(); - const absolute = this.constructCivilCurves(aligData, "absolute", absLength, lineMat); - const alignment = { horizontal, vertical, absolute }; - if (!fragmentsGroup.civilData) { - fragmentsGroup.civilData = { - alignments: new Map(), + const civil = group.civil(); + if (civil) { + const matArray = civil.coordinationMatrixArray(); + const coordinationMatrix = new THREE$1.Matrix4(); + if (matArray) { + coordinationMatrix.fromArray(matArray); + } + fragmentsGroup.civilData = { alignments: new Map(), coordinationMatrix }; + const aligLength = civil.alignmentsLength(); + for (let i = 0; i < aligLength; i++) { + const lineMat = new THREE$1.LineBasicMaterial({ color: 0xffffff }); + const aligData = civil.alignments(i); + if (!aligData) { + throw new Error("Alignment not found!"); + } + const horLength = aligData.horizontalLength(); + const horizontal = this.constructCivilCurves(aligData, "horizontal", horLength, lineMat); + const verLength = aligData.verticalLength(); + const vertical = this.constructCivilCurves(aligData, "vertical", verLength, lineMat); + const absLength = aligData.horizontalLength(); + const absolute = this.constructCivilCurves(aligData, "absolute", absLength, lineMat); + const initialKP = aligData.initialPk(); + const alignment = { + horizontal, + vertical, + absolute, + initialKP, }; + fragmentsGroup.civilData.alignments.set(i, alignment); } - fragmentsGroup.civilData.alignments.set(i, alignment); } // fragmentsGroup.ifcCivil?.horizontalAlignments fragmentsGroup.uuid = group.id() || fragmentsGroup.uuid; @@ -101398,9 +101464,9 @@ class CivilReader { const horizontal = this.getCurves(alignment.horizontal); const vertical = this.getCurves(alignment.vertical); const count = alignments.size; - alignments.set(count, { horizontal, vertical, absolute }); + alignments.set(count, { horizontal, vertical, absolute, initialKP: 0 }); } - return { alignments }; + return { alignments, coordinationMatrix: new THREE$1.Matrix4() }; } return undefined; } @@ -109460,7 +109526,7 @@ class GeometryCullerRenderer extends CullerRenderer { * * By David Fahlander, david.fahlander@gmail.com * - * Version 3.2.6, Tue Feb 13 2024 + * Version 3.2.4, Tue May 30 2023 * * https://dexie.org * @@ -109554,7 +109620,7 @@ function tryCatch(fn, onerror, args) { } } function getByKeyPath(obj, keyPath) { - if (typeof keyPath === 'string' && hasOwn(obj, keyPath)) + if (hasOwn(obj, keyPath)) return obj[keyPath]; if (!keyPath) return obj; @@ -109569,7 +109635,7 @@ function getByKeyPath(obj, keyPath) { var period = keyPath.indexOf('.'); if (period !== -1) { var innerObj = obj[keyPath.substr(0, period)]; - return innerObj == null ? undefined : getByKeyPath(innerObj, keyPath.substr(period + 1)); + return innerObj === undefined ? undefined : getByKeyPath(innerObj, keyPath.substr(period + 1)); } return undefined; } @@ -109637,7 +109703,7 @@ const concat = [].concat; function flatten(a) { return concat.apply([], a); } -const intrinsicTypeNames = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey" +const intrinsicTypeNames = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey" .split(',').concat(flatten([8, 16, 32, 64].map(num => ["Int", "Uint", "Float"].map(t => t + num + "Array")))).filter(t => _global[t]); const intrinsicTypes = intrinsicTypeNames.map(t => _global[t]); arrayToObject(intrinsicTypeNames, x => [x, true]); @@ -110698,7 +110764,7 @@ function tempTransaction(db, mode, storeNames, fn) { } } -const DEXIE_VERSION = '3.2.6'; +const DEXIE_VERSION = '3.2.4'; const maxString = String.fromCharCode(65535); const minKey = -Infinity; const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array."; @@ -110780,23 +110846,13 @@ let Table$3 = class Table { return this .where(keyPaths[0]) .equals(indexOrCrit[keyPaths[0]]); - const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(ix => { - if (ix.compound && - keyPaths.every(keyPath => ix.keyPath.indexOf(keyPath) >= 0)) { - for (let i = 0; i < keyPaths.length; ++i) { - if (keyPaths.indexOf(ix.keyPath[i]) === -1) - return false; - } - return true; - } - return false; - }).sort((a, b) => a.keyPath.length - b.keyPath.length)[0]; - if (compoundIndex && this.db._maxKey !== maxString) { - const keyPathsInValidOrder = compoundIndex.keyPath.slice(0, keyPaths.length); + const compoundIndex = this.schema.indexes.concat(this.schema.primKey).filter(ix => ix.compound && + keyPaths.every(keyPath => ix.keyPath.indexOf(keyPath) >= 0) && + ix.keyPath.every(keyPath => keyPaths.indexOf(keyPath) >= 0))[0]; + if (compoundIndex && this.db._maxKey !== maxString) return this - .where(keyPathsInValidOrder) - .equals(keyPathsInValidOrder.map(kp => indexOrCrit[kp])); - } + .where(compoundIndex.name) + .equals(compoundIndex.keyPath.map(kp => indexOrCrit[kp])); if (!compoundIndex && debug) console.warn(`The query ${JSON.stringify(indexOrCrit)} on ${this.name} would benefit of a ` + `compound index [${keyPaths.join('+')}]`); @@ -113079,82 +113135,69 @@ function dexieOpen(db) { } let resolveDbReady = state.dbReadyResolve, upgradeTransaction = null, wasCreated = false; - const tryOpenDB = () => new DexiePromise((resolve, reject) => { - throwIfCancelled(); - if (!indexedDB) - throw new exceptions.MissingAPI(); - const dbName = db.name; - const req = state.autoSchema ? - indexedDB.open(dbName) : - indexedDB.open(dbName, Math.round(db.verno * 10)); - if (!req) - throw new exceptions.MissingAPI(); - req.onerror = eventRejectHandler(reject); - req.onblocked = wrap(db._fireOnBlocked); - req.onupgradeneeded = wrap(e => { - upgradeTransaction = req.transaction; - if (state.autoSchema && !db._options.allowEmptyDB) { - req.onerror = preventDefault; - upgradeTransaction.abort(); - req.result.close(); - const delreq = indexedDB.deleteDatabase(dbName); - delreq.onsuccess = delreq.onerror = wrap(() => { - reject(new exceptions.NoSuchDatabase(`Database ${dbName} doesnt exist`)); - }); - } - else { - upgradeTransaction.onerror = eventRejectHandler(reject); - var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion; - wasCreated = oldVer < 1; - db._novip.idbdb = req.result; - runUpgraders(db, oldVer / 10, upgradeTransaction, reject); - } - }, reject); - req.onsuccess = wrap(() => { - upgradeTransaction = null; - const idbdb = db._novip.idbdb = req.result; - const objectStoreNames = slice(idbdb.objectStoreNames); - if (objectStoreNames.length > 0) - try { - const tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly'); - if (state.autoSchema) - readGlobalSchema(db, idbdb, tmpTrans); - else { - adjustToExistingIndexNames(db, db._dbSchema, tmpTrans); - if (!verifyInstalledSchema(db, tmpTrans)) { - console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.`); - } - } - generateMiddlewareStacks(db, tmpTrans); + return DexiePromise.race([openCanceller, (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(() => new DexiePromise((resolve, reject) => { + throwIfCancelled(); + if (!indexedDB) + throw new exceptions.MissingAPI(); + const dbName = db.name; + const req = state.autoSchema ? + indexedDB.open(dbName) : + indexedDB.open(dbName, Math.round(db.verno * 10)); + if (!req) + throw new exceptions.MissingAPI(); + req.onerror = eventRejectHandler(reject); + req.onblocked = wrap(db._fireOnBlocked); + req.onupgradeneeded = wrap(e => { + upgradeTransaction = req.transaction; + if (state.autoSchema && !db._options.allowEmptyDB) { + req.onerror = preventDefault; + upgradeTransaction.abort(); + req.result.close(); + const delreq = indexedDB.deleteDatabase(dbName); + delreq.onsuccess = delreq.onerror = wrap(() => { + reject(new exceptions.NoSuchDatabase(`Database ${dbName} doesnt exist`)); + }); } - catch (e) { + else { + upgradeTransaction.onerror = eventRejectHandler(reject); + var oldVer = e.oldVersion > Math.pow(2, 62) ? 0 : e.oldVersion; + wasCreated = oldVer < 1; + db._novip.idbdb = req.result; + runUpgraders(db, oldVer / 10, upgradeTransaction, reject); } - connections.push(db); - idbdb.onversionchange = wrap(ev => { - state.vcFired = true; - db.on("versionchange").fire(ev); - }); - idbdb.onclose = wrap(ev => { - db.on("close").fire(ev); - }); - if (wasCreated) - _onDatabaseCreated(db._deps, dbName); - resolve(); - }, reject); - }).catch(err => { - if (err && err.name === 'UnknownError' && state.PR1398_maxLoop > 0) { - state.PR1398_maxLoop--; - console.warn('Dexie: Workaround for Chrome UnknownError on open()'); - return tryOpenDB(); - } - else { - return DexiePromise.reject(err); - } - }); - return DexiePromise.race([ - openCanceller, - (typeof navigator === 'undefined' ? DexiePromise.resolve() : idbReady()).then(tryOpenDB) - ]).then(() => { + }, reject); + req.onsuccess = wrap(() => { + upgradeTransaction = null; + const idbdb = db._novip.idbdb = req.result; + const objectStoreNames = slice(idbdb.objectStoreNames); + if (objectStoreNames.length > 0) + try { + const tmpTrans = idbdb.transaction(safariMultiStoreFix(objectStoreNames), 'readonly'); + if (state.autoSchema) + readGlobalSchema(db, idbdb, tmpTrans); + else { + adjustToExistingIndexNames(db, db._dbSchema, tmpTrans); + if (!verifyInstalledSchema(db, tmpTrans)) { + console.warn(`Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.`); + } + } + generateMiddlewareStacks(db, tmpTrans); + } + catch (e) { + } + connections.push(db); + idbdb.onversionchange = wrap(ev => { + state.vcFired = true; + db.on("versionchange").fire(ev); + }); + idbdb.onclose = wrap(ev => { + db.on("close").fire(ev); + }); + if (wasCreated) + _onDatabaseCreated(db._deps, dbName); + resolve(); + }, reject); + }))]).then(() => { throwIfCancelled(); state.onReadyBeingFired = []; return DexiePromise.resolve(vip(() => db.on.ready.fire(db.vip))).then(function fireRemainders() { @@ -121955,7 +121998,9 @@ class RoadNavigator extends Component { } const mousePositionSphere = new THREE$1.Mesh(new THREE$1.SphereGeometry(0.5), new THREE$1.MeshBasicMaterial({ color: 0xff0000 })); scene.add(mousePositionSphere); - this.scene.uiElement.get("container").domElement.addEventListener("mousemove", (event) => { + this.scene.uiElement + .get("container") + .domElement.addEventListener("mousemove", (event) => { const dom = this.scene.uiElement.get("container").domElement; const mouse = new THREE$1.Vector2(); const rect = dom.getBoundingClientRect(); @@ -121977,7 +122022,9 @@ class RoadNavigator extends Component { for (const curve of this._curves) { curveMesh.push(curve.mesh); } - this.scene.uiElement.get("container").domElement.addEventListener("click", (event) => { + this.scene.uiElement + .get("container") + .domElement.addEventListener("click", (event) => { const dom = this.scene.uiElement.get("container").domElement; const mouse = new THREE$1.Vector2(); const rect = dom.getBoundingClientRect(); diff --git a/src/civil/RoadNavigator/index.ts b/src/civil/RoadNavigator/index.ts index cf53f38dc..456ab2dc1 100644 --- a/src/civil/RoadNavigator/index.ts +++ b/src/civil/RoadNavigator/index.ts @@ -3,7 +3,7 @@ import * as FRAGS from "bim-fragment"; import { FragmentsGroup } from "bim-fragment"; import { Component, Event } from "../../base-types"; import { Components, Simple2DScene } from "../../core"; -import { CurveHighlighter } from "./civil-road/curve-highlighter"; +import { CurveHighlighter } from "./src/curve-highlighter"; export abstract class RoadNavigator extends Component { enabled = true; @@ -69,21 +69,23 @@ export abstract class RoadNavigator extends Component { new THREE.MeshBasicMaterial({ color: 0xff0000 }) ); scene.add(mousePositionSphere); - this.scene.uiElement.get("container").domElement.addEventListener("mousemove", (event) => { - const dom = this.scene.uiElement.get("container").domElement; - const mouse = new THREE.Vector2(); - const rect = dom.getBoundingClientRect(); - mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; - mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; - const raycaster = new THREE.Raycaster(); - raycaster.setFromCamera(mouse, this.scene.camera); - const intersects = raycaster.intersectObjects(curveMesh); - if (intersects.length > 0) { - const intersect = intersects[0]; - const { point } = intersect; - mousePositionSphere.position.copy(point); - } - }); + this.scene.uiElement + .get("container") + .domElement.addEventListener("mousemove", (event) => { + const dom = this.scene.uiElement.get("container").domElement; + const mouse = new THREE.Vector2(); + const rect = dom.getBoundingClientRect(); + mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; + mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; + const raycaster = new THREE.Raycaster(); + raycaster.setFromCamera(mouse, this.scene.camera); + const intersects = raycaster.intersectObjects(curveMesh); + if (intersects.length > 0) { + const intersect = intersects[0]; + const { point } = intersect; + mousePositionSphere.position.copy(point); + } + }); this.setupEvents(); } @@ -94,20 +96,22 @@ export abstract class RoadNavigator extends Component { curveMesh.push(curve.mesh); } - this.scene.uiElement.get("container").domElement.addEventListener("click", (event) => { - const dom = this.scene.uiElement.get("container").domElement; - const mouse = new THREE.Vector2(); - const rect = dom.getBoundingClientRect(); - mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; - mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; - const raycaster = new THREE.Raycaster(); - raycaster.setFromCamera(mouse, this.scene.camera); - const intersects = raycaster.intersectObjects(curveMesh); - if (intersects.length > 0) { - const curve = intersects[0].object as THREE.LineSegments; - this.onHighlight.trigger(curve); - } - }); + this.scene.uiElement + .get("container") + .domElement.addEventListener("click", (event) => { + const dom = this.scene.uiElement.get("container").domElement; + const mouse = new THREE.Vector2(); + const rect = dom.getBoundingClientRect(); + mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; + mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1; + const raycaster = new THREE.Raycaster(); + raycaster.setFromCamera(mouse, this.scene.camera); + const intersects = raycaster.intersectObjects(curveMesh); + if (intersects.length > 0) { + const curve = intersects[0].object as THREE.LineSegments; + this.onHighlight.trigger(curve); + } + }); } dispose() { diff --git a/src/civil/RoadNavigator/civil-road/curve-highlighter.ts b/src/civil/RoadNavigator/src/curve-highlighter.ts similarity index 100% rename from src/civil/RoadNavigator/civil-road/curve-highlighter.ts rename to src/civil/RoadNavigator/src/curve-highlighter.ts diff --git a/src/fragments/FragmentIfcLoader/src/civil-reader.ts b/src/fragments/FragmentIfcLoader/src/civil-reader.ts index 4d29eeb06..d8327fe06 100644 --- a/src/fragments/FragmentIfcLoader/src/civil-reader.ts +++ b/src/fragments/FragmentIfcLoader/src/civil-reader.ts @@ -22,7 +22,6 @@ export class CivilReader { get(civilItems: any) { if (civilItems.IfcAlignment) { - const alignments = new Map(); for (const alignment of civilItems.IfcAlignment) { @@ -30,10 +29,10 @@ export class CivilReader { const horizontal = this.getCurves(alignment.horizontal); const vertical = this.getCurves(alignment.vertical); const count = alignments.size; - alignments.set(count, { horizontal, vertical, absolute }); + alignments.set(count, { horizontal, vertical, absolute, initialKP: 0 }); } - return { alignments }; + return { alignments, coordinationMatrix: new THREE.Matrix4() }; } return undefined; } diff --git a/yarn.lock b/yarn.lock index 32ce7f881..9e5c2ad06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1799,16 +1799,16 @@ __metadata: languageName: node linkType: hard -"bim-fragment@npm:1.5.0-alpha.2": - version: 1.5.0-alpha.2 - resolution: "bim-fragment@npm:1.5.0-alpha.2" +"bim-fragment@npm:1.5.0-alpha.3": + version: 1.5.0-alpha.3 + resolution: "bim-fragment@npm:1.5.0-alpha.3" dependencies: flatbuffers: ^23.3.3 three-mesh-bvh: 0.7.0 unzipit: 1.4.3 peerDependencies: three: ^0.160.1 - checksum: 7eed00c5da32436022dcc661f7731a8c22c414b91098ebc25b4be6bce70b814a21679e7b2e2f8bd27a3b3a2c666eeb7b999338807e3feae5aa9b9f47a0754878 + checksum: 26bce65471bac47d573b63dda1b607356ab6cd84f2fe9479349924bc2628ac151edec8baedc2811cd9ee14d1398a7e3340bbc78416912dc7ca5f4625ac3947d2 languageName: node linkType: hard @@ -5876,7 +5876,7 @@ __metadata: "@types/three": 0.160.0 "@typescript-eslint/eslint-plugin": ^4.27.0 "@typescript-eslint/parser": ^4.27.0 - bim-fragment: 1.5.0-alpha.2 + bim-fragment: 1.5.0-alpha.3 camera-controls: 2.7.3 cpy-cli: ^3.1.1 dexie: ^3.2.3 @@ -5905,7 +5905,7 @@ __metadata: unzipit: ^1.4.3 web-ifc: 0.0.51 peerDependencies: - bim-fragment: 1.5.0-alpha.2 + bim-fragment: 1.5.0-alpha.3 three: ^0.160.1 web-ifc: 0.0.51 languageName: unknown