Sfoglia il codice sorgente

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

master
Palash Bansal 11 mesi fa
parent
commit
98d250bede
Nessun account collegato all'indirizzo email del committer

+ 1
- 0
src/assetmanager/import/DRACOLoader2.ts Vedi File

export class DRACOLoader2 extends DRACOLoader implements ILoader<BufferGeometry, Mesh|undefined> { export class DRACOLoader2 extends DRACOLoader implements ILoader<BufferGeometry, Mesh|undefined> {
public encoderPending: Promise<any>|null = null public encoderPending: Promise<any>|null = null
public encoderConfig: any = {type: 'js'} 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://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/' // public static DRACO_LIBRARY_PATH = 'https://www.gstatic.com/draco/versioned/decoders/1.4.1/'

+ 8
- 0
src/assetmanager/import/GLTFLoader2.ts Vedi File

// loads the viewer config and handles loading the draco loader for extension // loads the viewer config and handles loading the draco loader for extension
gltfViewerParser = (viewer: ThreeViewer): (p: GLTFParser)=>GLTFLoaderPlugin => { gltfViewerParser = (viewer: ThreeViewer): (p: GLTFParser)=>GLTFLoaderPlugin => {
return (parser: GLTFParser) => { return (parser: GLTFParser) => {
parser.importOptions = this.importOptions || undefined
const getDependency = parser.getDependency const getDependency = parser.getDependency
parser.getDependency = async(type: string, index: number) => { parser.getDependency = async(type: string, index: number) => {
const res = await getDependency.call(parser, type, index) const res = await getDependency.call(parser, type, index)
parent.children.splice(index, 0, line2) 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 Vedi File



if (clearCurrentUserData === undefined) clearCurrentUserData = (<Material>parameters).isMaterial if (clearCurrentUserData === undefined) clearCurrentUserData = (<Material>parameters).isMaterial
if (clearCurrentUserData) this.userData = {} 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) iMaterialCommons.setValues(super.setValues).call(this, parameters)


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

Loading…
Annulla
Salva