From e64ee998733029c046cbae0349e2e127b67fa282 Mon Sep 17 00:00:00 2001 From: Juan Cazala Date: Wed, 3 Aug 2022 11:21:20 -0300 Subject: [PATCH] feat: added preview projection type (#115) * feat: added support for orthogonal projection and camera position * chore: fix linter warning --- .gitignore | 3 +- report/schemas.api.md | 35 ++++++++++++++++--- src/dapps/preview/index.ts | 1 + src/dapps/preview/preview-config.ts | 5 +++ src/dapps/preview/preview-options.ts | 5 +++ src/dapps/preview/preview-projection.ts | 20 +++++++++++ test/dapps/preview/preview-projection.spec.ts | 15 ++++++++ test/platform/item/emote/emote.spec.ts | 1 + 8 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 src/dapps/preview/preview-projection.ts create mode 100644 test/dapps/preview/preview-projection.spec.ts diff --git a/.gitignore b/.gitignore index 758c5a33..8627cdca 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ dist/ node_modules/ temp/ .DS_Store -.vscode \ No newline at end of file +.vscode +dcl-schemas-*.tgz \ No newline at end of file diff --git a/report/schemas.api.md b/report/schemas.api.md index 9c4e818c..cd3e3a7b 100644 --- a/report/schemas.api.md +++ b/report/schemas.api.md @@ -1195,11 +1195,15 @@ export type PreviewConfig = { }; emote: PreviewEmote | null; camera: PreviewCamera; + projection: PreviewProjection; autoRotateSpeed: number; centerBoundingBox: boolean; offsetX: number; offsetY: number; offsetZ: number; + cameraX: number; + cameraY: number; + cameraZ: number; wheelZoom: number; wheelPrecision: number; wheelStart: number; @@ -1353,10 +1357,14 @@ export type PreviewOptions = { zoom?: number | null; emote?: PreviewEmote | null; camera?: PreviewCamera | null; + projection?: PreviewProjection | null; autoRotateSpeed?: number | null; offsetX?: number | null; offsetY?: number | null; offsetZ?: number | null; + cameraX?: number | null; + cameraY?: number | null; + cameraZ?: number | null; wheelZoom?: number | null; wheelPrecision?: number | null; wheelStart?: number | null; @@ -1370,6 +1378,25 @@ export type PreviewOptions = { env?: PreviewEnv | null; }; +// Warning: (ae-missing-release-tag) "PreviewProjection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// Warning: (ae-missing-release-tag) "PreviewProjection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export enum PreviewProjection { + // (undocumented) + ORTHOGRAPHIC = "orthographic", + // (undocumented) + PERSPECTIVE = "perspective" +} + +// @public (undocumented) +export namespace PreviewProjection { + const // (undocumented) + schema: JSONSchema; + const // (undocumented) + validate: ValidateFunction; +} + // @alpha (undocumented) export enum PreviewType { // (undocumented) @@ -1967,10 +1994,10 @@ export namespace World { // src/dapps/order.ts:23:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha // src/dapps/order.ts:36:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha // src/dapps/preview/emote-definition.ts:16:5 - (ae-incompatible-release-tags) The symbol "representations" is marked as @public, but its signature references "EmoteRepresentationDefinition" which is marked as @alpha -// src/dapps/preview/preview-config.ts:9:3 - (ae-incompatible-release-tags) The symbol "wearable" is marked as @public, but its signature references "WearableDefinition" which is marked as @alpha -// src/dapps/preview/preview-config.ts:10:3 - (ae-incompatible-release-tags) The symbol "wearables" is marked as @public, but its signature references "WearableDefinition" which is marked as @alpha -// src/dapps/preview/preview-config.ts:11:3 - (ae-incompatible-release-tags) The symbol "bodyShape" is marked as @public, but its signature references "BodyShape" which is marked as @alpha -// src/dapps/preview/preview-config.ts:16:3 - (ae-incompatible-release-tags) The symbol "type" is marked as @public, but its signature references "PreviewType" which is marked as @alpha +// src/dapps/preview/preview-config.ts:10:3 - (ae-incompatible-release-tags) The symbol "wearable" is marked as @public, but its signature references "WearableDefinition" which is marked as @alpha +// src/dapps/preview/preview-config.ts:11:3 - (ae-incompatible-release-tags) The symbol "wearables" is marked as @public, but its signature references "WearableDefinition" which is marked as @alpha +// src/dapps/preview/preview-config.ts:12:3 - (ae-incompatible-release-tags) The symbol "bodyShape" is marked as @public, but its signature references "BodyShape" which is marked as @alpha +// src/dapps/preview/preview-config.ts:17:3 - (ae-incompatible-release-tags) The symbol "type" is marked as @public, but its signature references "PreviewType" which is marked as @alpha // src/dapps/preview/preview-message.ts:38:9 - (ae-incompatible-release-tags) The symbol "options" is marked as @public, but its signature references "PreviewOptions" which is marked as @alpha // src/dapps/sale.ts:22:3 - (ae-incompatible-release-tags) The symbol "network" is marked as @public, but its signature references "Network" which is marked as @alpha // src/dapps/sale.ts:23:3 - (ae-incompatible-release-tags) The symbol "chainId" is marked as @public, but its signature references "ChainId" which is marked as @alpha diff --git a/src/dapps/preview/index.ts b/src/dapps/preview/index.ts index f9c663e7..340265d0 100644 --- a/src/dapps/preview/index.ts +++ b/src/dapps/preview/index.ts @@ -6,6 +6,7 @@ export * from './preview-emote' export * from './preview-env' export * from './preview-message' export * from './preview-options' +export * from './preview-projection' export * from './preview-type' export * from './representation-definition' export * from './representation-with-blobs' diff --git a/src/dapps/preview/preview-config.ts b/src/dapps/preview/preview-config.ts index aa167ee3..bc3e0700 100644 --- a/src/dapps/preview/preview-config.ts +++ b/src/dapps/preview/preview-config.ts @@ -2,6 +2,7 @@ import { BodyShape } from '../../platform/item' import { EmoteDefinition } from './emote-definition' import { PreviewCamera } from './preview-camera' import { PreviewEmote } from './preview-emote' +import { PreviewProjection } from './preview-projection' import { PreviewType } from './preview-type' import { WearableDefinition } from './wearable-definition' @@ -22,11 +23,15 @@ export type PreviewConfig = { } emote: PreviewEmote | null camera: PreviewCamera + projection: PreviewProjection autoRotateSpeed: number centerBoundingBox: boolean offsetX: number offsetY: number offsetZ: number + cameraX: number + cameraY: number + cameraZ: number wheelZoom: number wheelPrecision: number wheelStart: number diff --git a/src/dapps/preview/preview-options.ts b/src/dapps/preview/preview-options.ts index d9b5ae71..9f052e4e 100644 --- a/src/dapps/preview/preview-options.ts +++ b/src/dapps/preview/preview-options.ts @@ -2,6 +2,7 @@ import { BodyShape } from '../../platform/item' import { PreviewCamera } from './preview-camera' import { PreviewEmote } from './preview-emote' import { PreviewEnv } from './preview-env' +import { PreviewProjection } from './preview-projection' import { WearableWithBlobs } from './wearable-with-blobs' /** @alpha */ @@ -21,10 +22,14 @@ export type PreviewOptions = { zoom?: number | null emote?: PreviewEmote | null camera?: PreviewCamera | null + projection?: PreviewProjection | null autoRotateSpeed?: number | null offsetX?: number | null offsetY?: number | null offsetZ?: number | null + cameraX?: number | null + cameraY?: number | null + cameraZ?: number | null wheelZoom?: number | null wheelPrecision?: number | null wheelStart?: number | null diff --git a/src/dapps/preview/preview-projection.ts b/src/dapps/preview/preview-projection.ts new file mode 100644 index 00000000..3768926f --- /dev/null +++ b/src/dapps/preview/preview-projection.ts @@ -0,0 +1,20 @@ +import { + JSONSchema, + generateLazyValidator, + ValidateFunction +} from '../../validation' + +export enum PreviewProjection { + ORTHOGRAPHIC = 'orthographic', + PERSPECTIVE = 'perspective' +} + +export namespace PreviewProjection { + export const schema: JSONSchema = { + type: 'string', + enum: Object.values(PreviewProjection) + } + + export const validate: ValidateFunction = + generateLazyValidator(schema) +} diff --git a/test/dapps/preview/preview-projection.spec.ts b/test/dapps/preview/preview-projection.spec.ts new file mode 100644 index 00000000..56a8fef5 --- /dev/null +++ b/test/dapps/preview/preview-projection.spec.ts @@ -0,0 +1,15 @@ +import expect from 'expect' +import { PreviewProjection } from '../../../src' +import { testTypeSignature } from '../../test-utils' + +describe('PreviewProjection tests', () => { + const previewProjection: PreviewProjection = PreviewProjection.PERSPECTIVE + + testTypeSignature(PreviewProjection, previewProjection) + + it('static tests must pass', () => { + expect(PreviewProjection.validate(previewProjection)).toEqual(true) + expect(PreviewProjection.validate(null)).toEqual(false) + expect(PreviewProjection.validate({})).toEqual(false) + }) +}) diff --git a/test/platform/item/emote/emote.spec.ts b/test/platform/item/emote/emote.spec.ts index f3c27182..3aab7b7f 100644 --- a/test/platform/item/emote/emote.spec.ts +++ b/test/platform/item/emote/emote.spec.ts @@ -271,6 +271,7 @@ describe('Emote tests', () => { '52c312f5e5524739388af971cddb526c3b49ba31ec77abc07ca01f5b113f1eba' } } + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { image, ...baseEmoteWithoutImage } = baseEmote const notThirdPartyEmote = { ...baseEmoteWithoutImage,