This commit is contained in:
AlexandruPopovici 2024-07-05 23:09:45 +03:00
Родитель ccd1c14e09
Коммит f37dce3539
3 изменённых файлов: 28 добавлений и 2 удалений

Просмотреть файл

@ -105,7 +105,7 @@ const getStream = () => {
// prettier-ignore
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8?c=%5B-7.66134,10.82932,6.41935,-0.07739,-13.88552,1.8697,0,1%5D'
// Revit sample house (good for bim-like stuff with many display meshes)
'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://latest.speckle.dev/streams/c1faab5c62/commits/ab1a1ab2b6'
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://latest.speckle.dev/streams/58b5648c4d/commits/60371ecb2d'
@ -388,6 +388,9 @@ const getStream = () => {
// 'https://app.speckle.systems/projects/122448a81e/models/f21aff1f4a'
// Thin plane
// 'https://app.speckle.systems/projects/20f72acc58/models/2cf8a736f8'
// Rhino sRGB vertex colors
// 'https://app.speckle.systems/projects/47bbaf594f/models/ef78e94f72'
'https://app.speckle.systems/projects/47bbaf594f/models/de52414725f8937b1f0e2f550ef9ca52'
)
}

Просмотреть файл

@ -605,7 +605,9 @@ export default class SpeckleRenderer {
private addBatch(batch: Batch, parent: Object3D) {
const batchRenderable = batch.renderObject
parent.add(batch.renderObject)
if (batchRenderable instanceof SpeckleMesh) {
parent.add(batchRenderable.TAS.bvhHelper)
}
if (batch.geometryType === GeometryType.MESH) {
batchRenderable.traverse((obj: Object3D) => {
if (obj instanceof Mesh) {

Просмотреть файл

@ -2,14 +2,19 @@ import {
Box3,
Box3Helper,
BufferAttribute,
BufferGeometry,
Color,
Float32BufferAttribute,
FrontSide,
Material,
Matrix4,
Mesh,
Ray,
Side,
Uint32BufferAttribute,
Vector3
} from 'three'
import { MeshBVHVisualizer } from 'three-mesh-bvh'
import { ExtendedTriangle, HitPointInfo } from 'three-mesh-bvh'
import { BatchObject } from '../batching/BatchObject'
import type {
@ -59,6 +64,7 @@ export class TopLevelAccelerationStructure {
public boxHelpers: Box3Helper[] = []
public accelerationStructure: AccelerationStructure
public bvhHelper: MeshBVHVisualizer
public constructor(batchObjects: BatchObject[]) {
this.batchObjects = batchObjects
@ -99,6 +105,21 @@ export class TopLevelAccelerationStructure {
this.accelerationStructure.outputTransform = new Matrix4()
this.accelerationStructure.inputOriginTransform = new Matrix4()
this.accelerationStructure.outputOriginTransfom = new Matrix4()
const geom = new BufferGeometry()
geom.setIndex(new Uint32BufferAttribute(new Uint32Array(indices), 1))
geom.setAttribute(
'position',
new Float32BufferAttribute(new Float32Array(vertices), 3)
)
geom.computeBoundingBox()
const mesh = new Mesh(geom)
mesh.layers.set(ObjectLayers.OVERLAY)
mesh.geometry.boundsTree = this.accelerationStructure.bvh
this.bvhHelper = new MeshBVHVisualizer(mesh)
this.bvhHelper.layers.set(ObjectLayers.OVERLAY)
this.bvhHelper.children[0].layers.set(ObjectLayers.OVERLAY)
this.bvhHelper.update()
}
private updateVertArray(box: Box3, offset: number, outPositions: number[]) {