fix(viewer-lib): Fixed OBJLoder not working properly (#5731)
This commit is contained in:
committed by
GitHub
parent
06c5529024
commit
68d5881179
@@ -183,6 +183,7 @@ import {
|
||||
ObjectPickConfiguration,
|
||||
DefaultObjectPickConfiguration
|
||||
} from './modules/SpeckleRenderer.js'
|
||||
import { ChunkArray, VirtualArray } from './modules/converter/VirtualArray.js'
|
||||
export {
|
||||
Viewer,
|
||||
LegacyViewer,
|
||||
@@ -305,7 +306,9 @@ export {
|
||||
SpeckleMesh,
|
||||
SpeckleInstancedMesh,
|
||||
CameraControllerOptions,
|
||||
NearPlaneCalculation
|
||||
NearPlaneCalculation,
|
||||
ChunkArray,
|
||||
VirtualArray
|
||||
}
|
||||
|
||||
export type {
|
||||
|
||||
@@ -29,8 +29,6 @@ export enum GeometryAttributes {
|
||||
INDEX = 'INDEX'
|
||||
}
|
||||
|
||||
type AttributeValue = ChunkArray
|
||||
|
||||
// Required keys
|
||||
type RequiredKeys = GeometryAttributes.POSITION | GeometryAttributes.INDEX
|
||||
|
||||
@@ -39,9 +37,9 @@ type OptionalKeys = Exclude<GeometryAttributes, RequiredKeys>
|
||||
|
||||
// Final shape: required + optional keys
|
||||
type GeometryAttributesShape = {
|
||||
[K in RequiredKeys]: AttributeValue
|
||||
[K in RequiredKeys]: ChunkArray
|
||||
} & {
|
||||
[K in OptionalKeys]?: AttributeValue
|
||||
[K in OptionalKeys]?: ChunkArray
|
||||
}
|
||||
|
||||
export interface GeometryData {
|
||||
@@ -94,7 +92,7 @@ export class Geometry {
|
||||
}
|
||||
|
||||
static mergeGeometryAttribute(
|
||||
attributes: AttributeValue[],
|
||||
attributes: ChunkArray[],
|
||||
target: Float32Array | Float64Array
|
||||
): ArrayLike<number> {
|
||||
let offset = 0
|
||||
@@ -110,8 +108,8 @@ export class Geometry {
|
||||
}
|
||||
|
||||
static mergeIndexAttribute(
|
||||
indexAttributes: AttributeValue[],
|
||||
positionAttributes: AttributeValue[]
|
||||
indexAttributes: ChunkArray[],
|
||||
positionAttributes: ChunkArray[]
|
||||
): number[] {
|
||||
let indexOffset = 0
|
||||
const mergedIndex = []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Matrix4 } from 'three'
|
||||
import { type NodeData } from '../../../index.js'
|
||||
import { MathUtils, Matrix4 } from 'three'
|
||||
import { ChunkArray, type NodeData } from '../../../index.js'
|
||||
import { type GeometryData } from '../../converter/Geometry.js'
|
||||
import { GeometryConverter, SpeckleType } from '../GeometryConverter.js'
|
||||
import { mergeVertices } from 'three/examples/jsm/utils/BufferGeometryUtils.js'
|
||||
@@ -64,13 +64,30 @@ export class ObjGeometryConverter extends GeometryConverter {
|
||||
if (!node.raw.geometry.index || node.raw.geometry.index.array.length === 0) {
|
||||
node.raw.geometry = mergeVertices(node.raw.geometry)
|
||||
}
|
||||
|
||||
return {
|
||||
attributes: {
|
||||
POSITION: Array.from(node.raw.geometry.attributes.position.array),
|
||||
INDEX: Array.from(node.raw.geometry.index.array),
|
||||
POSITION: new ChunkArray([
|
||||
{
|
||||
data: node.raw.geometry.attributes.position.array,
|
||||
id: MathUtils.generateUUID(),
|
||||
references: 1
|
||||
}
|
||||
]),
|
||||
INDEX: new ChunkArray([
|
||||
{
|
||||
data: node.raw.geometry.index.array,
|
||||
id: MathUtils.generateUUID(),
|
||||
references: 1
|
||||
}
|
||||
]),
|
||||
...(node.raw.geometry.attributes.color && {
|
||||
COLOR: Array.from(node.raw.geometry.attributes.color.array)
|
||||
COLOR: new ChunkArray([
|
||||
{
|
||||
data: node.raw.geometry.attributes.color.array,
|
||||
id: MathUtils.generateUUID(),
|
||||
references: 1
|
||||
}
|
||||
])
|
||||
})
|
||||
},
|
||||
bakeTransform: new Matrix4().makeScale(
|
||||
@@ -79,6 +96,6 @@ export class ObjGeometryConverter extends GeometryConverter {
|
||||
conversionFactor
|
||||
),
|
||||
transform: null
|
||||
} as GeometryData
|
||||
} satisfies GeometryData
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user