mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-19 22:24:17 +01:00
cleaner constant
This commit is contained in:
@@ -3,6 +3,7 @@ import {unpartition} from "@gltf-transform/functions";
|
||||
|
||||
let io = new WebIO();
|
||||
export let extrasNameKey = "__yacv_name";
|
||||
export let extrasNameValueHelpers = "__helpers";
|
||||
|
||||
/**
|
||||
* Loads a GLB model from a URL and adds it to the document or replaces it if the names match.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Ref, ShallowRef} from 'vue';
|
||||
import {Document} from '@gltf-transform/core';
|
||||
import {extrasNameKey, mergeFinalize, mergePartial, removeModel, toBuffer} from "./gltf";
|
||||
import {extrasNameKey, extrasNameValueHelpers, mergeFinalize, mergePartial, removeModel, toBuffer} from "./gltf";
|
||||
import {newAxes, newGridBox} from "./helpers";
|
||||
import {Box3, Matrix4, Vector3} from 'three';
|
||||
|
||||
@@ -13,7 +13,7 @@ export class SceneMgr {
|
||||
// Start merging into the current document, replacing or adding as needed
|
||||
document.value = await mergePartial(url, name, document.value);
|
||||
|
||||
if (name !== "__helpers") {
|
||||
if (name !== extrasNameValueHelpers) {
|
||||
// Reload the helpers to fit the new model
|
||||
await this.reloadHelpers(sceneUrl, document);
|
||||
} else {
|
||||
@@ -35,7 +35,7 @@ export class SceneMgr {
|
||||
newAxes(helpersDoc, bb.getSize(new Vector3()).multiplyScalar(0.5), transform);
|
||||
newGridBox(helpersDoc, bb.getSize(new Vector3()), transform);
|
||||
let helpersUrl = URL.createObjectURL(new Blob([await toBuffer(helpersDoc)]));
|
||||
await SceneMgr.loadModel(sceneUrl, document, "__helpers", helpersUrl);
|
||||
await SceneMgr.loadModel(sceneUrl, document, extrasNameValueHelpers, helpersUrl);
|
||||
}
|
||||
|
||||
static getBoundingBox(document: ShallowRef<Document>): Box3 {
|
||||
@@ -43,7 +43,7 @@ export class SceneMgr {
|
||||
let bbMin: number[] = [1e6, 1e6, 1e6];
|
||||
let bbMax: number[] = [-1e6, -1e6, -1e6];
|
||||
document.value.getRoot().listNodes().forEach(node => {
|
||||
if ((node.getExtras()[extrasNameKey] ?? "__helpers") === "__helpers") return;
|
||||
if ((node.getExtras()[extrasNameKey] ?? extrasNameValueHelpers) === extrasNameValueHelpers) return;
|
||||
let transform = new Matrix4(...node.getWorldMatrix());
|
||||
for (let prim of node.getMesh()?.listPrimitives() ?? []) {
|
||||
let accessor = prim.getAttribute('POSITION');
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
VSpacer,
|
||||
VTooltip,
|
||||
} from "vuetify/lib/components";
|
||||
import {extrasNameKey} from "../misc/gltf";
|
||||
import {extrasNameKey, extrasNameValueHelpers} from "../misc/gltf";
|
||||
import {Document, Mesh} from "@gltf-transform/core";
|
||||
import {inject, ref, ShallowRef, watch} from "vue";
|
||||
import type ModelViewerWrapper from "../viewer/ModelViewerWrapper.vue";
|
||||
@@ -181,7 +181,7 @@ function onModelLoad() {
|
||||
// back faces with a different material.
|
||||
child.material.side = FrontSide;
|
||||
|
||||
if (modelName !== "__helpers") {
|
||||
if (modelName !== extrasNameValueHelpers) {
|
||||
// The back of the material only writes to the stencil buffer the areas
|
||||
// that should be covered by the plane, but does not render anything
|
||||
let backChild = child.clone();
|
||||
|
||||
Reference in New Issue
Block a user