Skip to content
Snippets Groups Projects
Commit f3de5aa5 authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: use supplied xform

parent 661d37cc
No related branches found
No related tags found
No related merge requests found
import { Observable, Subject } from "rxjs"
import { getUuid } from "src/util/fn"
import { IMessagingActions, IMessagingActionTmpl } from "../types"
import { IMessagingActions, IMessagingActionTmpl, TVec4 } from "../types"
import { INmvTransform } from "./type"
export const TYPE = 'bas.datasource'
......@@ -56,8 +57,9 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
if (!transformations[0]) {
return subject.error(`transformations[0] must be defined`)
}
const { toSpace } = transformations[0]
const { toSpace, params } = transformations[0] as INmvTransform
const { A, b } = params
const iavSpace = translateSpace(toSpace)
if (!iavSpace) {
return subject.error(`toSpace with id ${toSpace} cannot be found.`)
......@@ -96,7 +98,15 @@ export const processJsonLd = (json: { [key: string]: any }): Observable<IMessagi
unload: () => {
URL.revokeObjectURL(tmpUrl)
},
url: tmpUrl
url: tmpUrl,
resourceParam: {
transform: [
[...A[0], b[0]] as TVec4,
[...A[1], b[1]] as TVec4,
[...A[2], b[2]] as TVec4,
[0, 0, 0, 1],
]
}
}
subject.next({
type: 'loadResource',
......
import { TMat3, TVec3 } from "../types";
export interface INmvTransform {
['@type']: 'bas.AffineTransformation'
fromSpace: string
toSpace: string
params: {
A: TMat3
b: TVec3
}
}
\ No newline at end of file
......@@ -8,11 +8,21 @@ interface IResourceType {
swc: string
}
export type TVec4 = [number, number, number, number]
export type TVec3 = [number, number, number]
export type TMat3 = [TVec3, TVec3, TVec3]
export type TMat4 = [TVec4, TVec4, TVec4, TVec4]
interface ICommonResParam {
transform: TMat4
}
interface ILoadResource {
['@id']: string
['@type']: keyof IResourceType
url: string
unload: () => void
resourceParam: ICommonResParam
}
interface IUnloadResource {
......
......@@ -63,11 +63,12 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
unload,
url,
["@type"]: type,
["@id"]: swcLayerUuid
["@id"]: swcLayerUuid,
resourceParam
} = payload
if (type === 'swc') {
const { transform } = resourceParam
const layer = {
name: swcLayerUuid,
id: swcLayerUuid,
......@@ -77,6 +78,7 @@ export class MessagingGlue implements IWindowMessaging, OnDestroy {
"segments": [
"1"
],
transform,
}
this.store.dispatch(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment