feat(viewer-lib): Loader now allows unknown type for resourceData, so each loader can treat it the way it wants (#3981)
This commit is contained in:
committed by
GitHub
parent
c382064585
commit
e9997f1c62
@@ -20,7 +20,6 @@ import {
|
||||
import { SectionTool } from '@speckle/viewer'
|
||||
import { SectionOutlines } from '@speckle/viewer'
|
||||
import { ViewModesKeys } from './Extensions/ViewModesKeys'
|
||||
// import { JSONSpeckleStream } from './JSONSpeckleStream'
|
||||
import { BoxSelection } from './Extensions/BoxSelection'
|
||||
import { PassReader } from './Extensions/PassReader'
|
||||
|
||||
|
||||
@@ -14,15 +14,12 @@ export interface LoaderEventPayload {
|
||||
|
||||
export abstract class Loader extends EventEmitter {
|
||||
protected _resource: string
|
||||
protected _resourceData: string | ArrayBuffer | undefined
|
||||
protected _resourceData: unknown
|
||||
|
||||
public abstract get resource(): string
|
||||
public abstract get finished(): boolean
|
||||
|
||||
protected constructor(
|
||||
resource: string,
|
||||
resourceData?: string | ArrayBuffer | undefined
|
||||
) {
|
||||
protected constructor(resource: string, resourceData?: unknown) {
|
||||
super()
|
||||
this._resource = resource
|
||||
this._resourceData = resourceData
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ObjLoader extends Loader {
|
||||
return this.isFinished
|
||||
}
|
||||
|
||||
public constructor(targetTree: WorldTree, resource: string, resourceData?: string) {
|
||||
public constructor(targetTree: WorldTree, resource: string, resourceData?: unknown) {
|
||||
super(resource, resourceData)
|
||||
this.tree = targetTree
|
||||
this.baseLoader = new OBJLoader()
|
||||
|
||||
@@ -26,7 +26,7 @@ export class SpeckleLoader extends Loader {
|
||||
resource: string,
|
||||
authToken?: string,
|
||||
enableCaching?: boolean,
|
||||
resourceData?: string | ArrayBuffer
|
||||
resourceData?: unknown
|
||||
) {
|
||||
super(resource, resourceData)
|
||||
this.tree = targetTree
|
||||
@@ -49,10 +49,9 @@ export class SpeckleLoader extends Loader {
|
||||
resource: string,
|
||||
authToken?: string,
|
||||
enableCaching?: boolean,
|
||||
resourceData?: string | ArrayBuffer
|
||||
resourceData?: unknown
|
||||
): ObjectLoader {
|
||||
resourceData
|
||||
|
||||
let token = undefined
|
||||
try {
|
||||
token = authToken || (localStorage.getItem('AuthToken') as string | undefined)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { WorldTree } from '../../tree/WorldTree.js'
|
||||
import Logger from '../../utils/Logger.js'
|
||||
|
||||
export class SpeckleOfflineLoader extends SpeckleLoader {
|
||||
constructor(targetTree: WorldTree, resourceData: string, resourceId?: string) {
|
||||
constructor(targetTree: WorldTree, resourceData: unknown, resourceId?: string) {
|
||||
super(targetTree, resourceId || '', undefined, undefined, resourceData)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class SpeckleOfflineLoader extends SpeckleLoader {
|
||||
_resource: string,
|
||||
_authToken?: string,
|
||||
_enableCaching?: boolean,
|
||||
resourceData?: string | ArrayBuffer
|
||||
resourceData?: unknown
|
||||
): ObjectLoader {
|
||||
return ObjectLoader.createFromJSON(resourceData as string)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user