MCPcopy Create free account
hub / github.com/beutton/browser-flight-simulator / load

Function load

packages/core/src/DataLoader.ts:80–117  ·  view source on GitHub ↗
(
    url: string,
    onLoad: (data: T) => void,
    onProgress?: (event: ProgressEvent) => void,
    onError?: (error: unknown) => void
  )

Source from the content-addressed store, hash-verified

78 readonly parameters: DataTextureParameters & Data3DTextureParameters = {}
79
80 override load(
81 url: string,
82 onLoad: (data: T) => void,
83 onProgress?: (event: ProgressEvent) => void,
84 onError?: (error: unknown) => void
85 ): void {
86 const texture = new this.Texture()
87 const loader = new this.TypedArrayLoader(this.manager)
88 loader.setRequestHeader(this.requestHeader)
89 loader.setPath(this.path)
90 loader.setWithCredentials(this.withCredentials)
91 loader.load(
92 url,
93 array => {
94 texture.image.data =
95 array instanceof Float16Array ? new Uint16Array(array.buffer) : array
96 const { width, height, depth, ...params } = this.parameters
97 if (width != null) {
98 texture.image.width = width
99 }
100 if (height != null) {
101 texture.image.height = height
102 }
103 if ('depth' in texture.image && depth != null) {
104 texture.image.depth = depth
105 }
106
107 // Populate the default texture type for the array type.
108 texture.type = getTextureDataType(array)
109
110 Object.assign(texture, params)
111 texture.needsUpdate = true
112 onLoad(texture)
113 },
114 onProgress,
115 onError
116 )
117 }
118}
119
120function createDataLoaderClass<

Callers

nothing calls this directly

Calls 2

getTextureDataTypeFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected