Преглед изворни кода

Pass in importOptions to GLTFParser, copy ior in PhysicalMaterial.setValues, add isDRACOLoader2

master
Palash Bansal пре 11 месеци
родитељ
комит
98d250bede
No account linked to committer's email address

+ 1
- 0
src/assetmanager/import/DRACOLoader2.ts Прегледај датотеку

@@ -7,6 +7,7 @@ import {PhysicalMaterial} from '../../core'
export class DRACOLoader2 extends DRACOLoader implements ILoader<BufferGeometry, Mesh|undefined> {
public encoderPending: Promise<any>|null = null
public encoderConfig: any = {type: 'js'}
readonly isDRACOLoader2 = true

public static DRACO_LIBRARY_PATH = 'https://cdn.jsdelivr.net/gh/google/draco@1.5.6/javascript/' // https://github.com/google/draco
// public static DRACO_LIBRARY_PATH = 'https://www.gstatic.com/draco/versioned/decoders/1.4.1/'

+ 8
- 0
src/assetmanager/import/GLTFLoader2.ts Прегледај датотеку

@@ -169,6 +169,7 @@ export class GLTFLoader2 extends GLTFLoader implements ILoader<GLTF, Object3D|un
// loads the viewer config and handles loading the draco loader for extension
gltfViewerParser = (viewer: ThreeViewer): (p: GLTFParser)=>GLTFLoaderPlugin => {
return (parser: GLTFParser) => {
parser.importOptions = this.importOptions || undefined
const getDependency = parser.getDependency
parser.getDependency = async(type: string, index: number) => {
const res = await getDependency.call(parser, type, index)
@@ -273,3 +274,10 @@ function convertToFatLine(line: Line) {
parent.children.splice(index, 0, line2)
}
}

declare module 'three/examples/jsm/loaders/GLTFLoader.js'{
export interface GLTFParser {
importOptions?: ImportAddOptions
// getDependency(type: string, index: number): Promise<Object3D|Texture|Line|LineSegments|LineLoop>
}
}

+ 2
- 0
src/core/material/PhysicalMaterial.ts Прегледај датотеку

@@ -180,6 +180,8 @@ export class PhysicalMaterial<TE extends IMaterialEventMap = IMaterialEventMap>

if (clearCurrentUserData === undefined) clearCurrentUserData = (<Material>parameters).isMaterial
if (clearCurrentUserData) this.userData = {}

if ((parameters as any).ior !== undefined) this.ior = (parameters as any).ior // ior is not serialized in MeshPhysicalMaterial.toJSON, so we need to set it here
iMaterialCommons.setValues(super.setValues).call(this, parameters)

if (!isFinite(this.attenuationDistance)) this.attenuationDistance = 0 // hack for ui

Loading…
Откажи
Сачувај