From 2e986acb37d5bed1ec3fe81777e8b36ca8c0aaea Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Tue, 8 Jan 2019 19:25:15 +0800 Subject: [PATCH 1/4] fix-quat-error (#3725) * fix-quat-error * fix module error --- cocos/3d/assets/index.js | 6 +++--- cocos/core/vmath/quat.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/3d/assets/index.js b/cocos/3d/assets/index.js index a368fc1256..539ad15695 100644 --- a/cocos/3d/assets/index.js +++ b/cocos/3d/assets/index.js @@ -24,9 +24,9 @@ ****************************************************************************/ export { default as AnimationClip } from "./animation-clip"; -export { default as AudioClip } from "./audio-clip"; -export { default as DomAudioClip } from "./dom-audio-clip"; -export { default as BitmapFont } from "./bitmap-font"; +export { AudioClip } from "./audio-clip"; +export { DOMAudioClip } from "./dom-audio-clip"; +export { BitmapFont } from "./bitmap-font"; export { default as EffectAsset } from "./effect-asset"; export { default as Material } from "./material"; export { default as Mesh } from "./mesh"; diff --git a/cocos/core/vmath/quat.ts b/cocos/core/vmath/quat.ts index a23f28ec23..0fcc1d0e0a 100644 --- a/cocos/core/vmath/quat.ts +++ b/cocos/core/vmath/quat.ts @@ -650,9 +650,9 @@ export default class quat { */ public static toEuler (out: Out, q: quat) { const { x, y, z, w } = q; - let heading: number = 0; - let attitude: number = 0; - let bank: number = 0; + let heading: number = NaN; + let attitude: number = NaN; + let bank: number = NaN; const test = x * y + z * w; if (test > 0.499999) { // singularity at north pole heading = 2 * Math.atan2(x, w); From bd3801fd3b9b02834bde046f48fb331fcd2f39e2 Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Tue, 8 Jan 2019 20:06:59 +0800 Subject: [PATCH 2/4] fix export errors (#3719) * fix export errors * Update tslint.json --- cocos/3d/assets/index.js | 1 - cocos/3d/assets/physics/material.ts | 1 + tslint.json | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cocos/3d/assets/index.js b/cocos/3d/assets/index.js index 539ad15695..6393ed3b4f 100644 --- a/cocos/3d/assets/index.js +++ b/cocos/3d/assets/index.js @@ -37,4 +37,3 @@ export { default as WebAudioClip } from "./web-audio-clip"; export { default as WxGameAudioClip } from "./wx-game-audio-clip"; export { PhysicsMaterial } from './physics/material'; -cc.PhysicsMaterial = PhysicsMaterial; \ No newline at end of file diff --git a/cocos/3d/assets/physics/material.ts b/cocos/3d/assets/physics/material.ts index b44256eab7..accaa91ba0 100644 --- a/cocos/3d/assets/physics/material.ts +++ b/cocos/3d/assets/physics/material.ts @@ -52,3 +52,4 @@ export class PhysicsMaterial extends Asset { return this._cannonMaterial; } } +cc.PhysicsMaterial = PhysicsMaterial; diff --git a/tslint.json b/tslint.json index 1ba95e26a4..f1676c13ea 100644 --- a/tslint.json +++ b/tslint.json @@ -8,7 +8,9 @@ "quotemark": [ true, "single" ], "no-console": false, "space-before-function-paren": true, - "max-classes-per-file": false + "max-classes-per-file": false, + "variable-name": false, + "object-literal-sort-keys": false }, "rulesDirectory": [] -} \ No newline at end of file +} From 855738d49b72ef67acbd0e113a07048cd84c5833 Mon Sep 17 00:00:00 2001 From: Leslie Leigh Date: Thu, 10 Jan 2019 22:27:43 +0800 Subject: [PATCH 3/4] Rollup build (#3735) * rollup-build rename to ts * add build-engine-cli * rename rollup result, because cc can be conflict * tsc not found --- .gitignore | 1 + package.json | 11 +++- rollup/build-engine-cli.ts | 99 +++++++++++++++++++++++++++++++++++ rollup/build-engine.ts | 103 +++++++++++++++++++++++++++++++++++++ rollup/config.js | 2 +- rollup/tsconfig.json | 60 +++++++++++++++++++++ 6 files changed, 273 insertions(+), 3 deletions(-) create mode 100644 rollup/build-engine-cli.ts create mode 100644 rollup/build-engine.ts create mode 100644 rollup/tsconfig.json diff --git a/.gitignore b/.gitignore index a3c739bd6c..ca53b140ee 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ node_modules /.project npm-debug.log DebugInfos.json +/rollup/out diff --git a/package.json b/package.json index 312dac8982..a4635ad24b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,9 @@ "build": "npm run build:dev && npm run build:min", "build:dev": "rollup -c ./rollup/config.js", "build:min": "uglifyjs ./bin/cocos-3d.dev.js --mangle --source-map -o ./bin/cocos-3d.min.js", - "dev": "rollup -w -c ./rollup/config.js" + "build-rollup": "tsc --build rollup/tsconfig.json", + "dev": "rollup -w -c ./rollup/config.js", + "postinstall": "npm run build-rollup" }, "repository": { "type": "git", @@ -26,6 +28,9 @@ "@babel/preset-env": "^7.2.0", "@babel/preset-typescript": "^7.1.0", "@types/cannon": "^0.1.3", + "@types/fs-extra": "^5.0.4", + "@types/uglify-js": "^3.0.4", + "@types/yargs": "^12.0.5", "aliasify": "^2.1.0", "async": "1.5.2", "babel-preset-env": "^1.2.2", @@ -35,6 +40,7 @@ "del": "1.2.0", "event-stream": "3.3.2", "fire-fs": "0.2.1", + "fs-extra": "^7.0.1", "fs-jetpack": "^1.1.0", "gulp": "^3.9.1", "gulp-babel": "6.1.2", @@ -70,6 +76,7 @@ "vinyl": "1.1.0", "vinyl-buffer": "1.0.0", "vinyl-source-stream": "1.0.0", - "watchify": "^3.7.0" + "watchify": "^3.7.0", + "yargs": "^12.0.5" } } diff --git a/rollup/build-engine-cli.ts b/rollup/build-engine-cli.ts new file mode 100644 index 0000000000..53edb0ca0a --- /dev/null +++ b/rollup/build-engine-cli.ts @@ -0,0 +1,99 @@ + +import yargs from 'yargs'; +import { build } from './build-engine'; + +yargs.option('platform', { type: 'string', alias: 'p' }); +yargs.option('flags', { type: 'array', alias: 'f' }); +yargs.option('destination', { type: 'string', alias: 'd' }); +yargs.boolean('sourcemap'); +yargs.boolean('compress'); + +const flags: IFlags = {}; +const argvFlags = yargs.argv.flags as (string[] | undefined); +if (argvFlags) { + argvFlags.forEach((argvFlag) => flags[argvFlag as keyof IFlags] = true); +} + +const globalDefs = getGlobalDefs(yargs.argv.platform as Platform, flags); + +build({ + compress: yargs.argv.compress as (boolean | undefined), + globalDefines: globalDefs, + inputPath: './index.js', + outputPath: yargs.argv.destination as string, + sourcemap: yargs.argv.sourcemap as (boolean | undefined), +}).then( + () => { + console.log(`Build successful.`); + }, + (reason: any) => { + console.error(`Build failed, reason:\n ${reason}`); + }, +); + +type Platform = 'editor' | 'preview' | 'build' | 'test'; + +interface IFlags { + jsb?: boolean; + runtime?: boolean; + wechatgame?: boolean; + qqplay?: boolean; + debug?: boolean; + nativeRenderer?: boolean; +} + +interface IGlobaldefines { + // Platform macros + CC_EDITOR?: boolean; + CC_PREVIEW?: boolean; + CC_BUILD?: boolean; + CC_TEST?: boolean; + + // Flag macros + CC_JSB?: boolean; + CC_RUNTIME?: boolean; + CC_WECHATGAME?: boolean; + CC_WECHATGAMESUB?: boolean; + CC_QQPLAY?: boolean; + CC_DEBUG?: boolean; + CC_NATIVERENDERER?: boolean; + + // Debug macros + CC_DEV?: boolean; + CC_SUPPORT_JIT?: boolean; +} + +function getGlobalDefs (platform: Platform, flags?: IFlags): object { + const PLATFORM_MACROS = ['CC_EDITOR', 'CC_PREVIEW', 'CC_BUILD', 'CC_TEST']; + + const FLAGS = ['jsb', 'runtime', 'wechatgame', 'wechatgameSub', 'qqplay', 'debug', 'nativeRenderer']; + + const platformMacro = 'CC_' + platform.toUpperCase(); + if (PLATFORM_MACROS.indexOf(platformMacro) === -1) { + throw new Error(`Unknown platform ${platform}.`); + } + const result: IGlobaldefines = {}; + for (const macro of PLATFORM_MACROS) { + result[macro as keyof IGlobaldefines] = (macro === platformMacro); + } + + if (flags) { + for (const flag in flags) { + if (flags.hasOwnProperty(flag) && flags[flag as keyof IFlags]) { + if (FLAGS.indexOf(flag) === -1) { + throw new Error('Unknown flag: ' + flag); + } + } + } + } + for (const flag of FLAGS) { + const macro = 'CC_' + flag.toUpperCase(); + result[macro as keyof IGlobaldefines] = !!(flags && flags[flag as keyof IFlags]); + } + + result.CC_DEV = result.CC_EDITOR || result.CC_PREVIEW || result.CC_TEST; + result.CC_DEBUG = result.CC_DEBUG || result.CC_DEV; + result.CC_SUPPORT_JIT = !(result.CC_WECHATGAME || result.CC_QQPLAY || result.CC_RUNTIME); + + return result; +} diff --git a/rollup/build-engine.ts b/rollup/build-engine.ts new file mode 100644 index 0000000000..4a437caf29 --- /dev/null +++ b/rollup/build-engine.ts @@ -0,0 +1,103 @@ + +import * as fs from 'fs-extra'; +import { rollup } from 'rollup'; +// @ts-ignore +import babel from 'rollup-plugin-babel'; +// @ts-ignore +import commonjs from 'rollup-plugin-commonjs'; +// @ts-ignore +import json from 'rollup-plugin-json'; +// @ts-ignore +import resolve from 'rollup-plugin-node-resolve'; +import { minify } from 'uglify-js'; + +export interface IBuildOptions { + inputPath: string; + outputPath: string; + globalDefines: object; + excludes?: string[]; + compress?: boolean; + sourcemap?: boolean; +} + +export async function build (options: IBuildOptions) { + console.log(`Options: ${JSON.stringify(options)}`); + const result = await _doBundle(options); + if (!result) { + return; + } + fs.writeFileSync(options.outputPath, result.code); +} + +async function _doBundle (options: IBuildOptions) { + let code = ''; + + const rollupPlugins = [ + resolve({ + extensions: ['.js', '.ts', '.json'], + jsnext: true, + main: true, + }), + + json({ + preferConst: true, + }), + + babel({ + extensions: ['.js', '.ts'], + highlightCode: true, + ignore: [ + 'node_modules/**', + ], + plugins: [ + ['@babel/plugin-proposal-decorators', { + legacy: true, + }], + ['@babel/plugin-proposal-class-properties', { + loose: true, + }], + ], + presets: [ + '@babel/preset-env', + '@babel/preset-typescript', + ], + }), + + commonjs({ + namedExports: { + cannon: ['CANNON', 'Shape'], + }, + }), + ]; + + const rollupBuild = await rollup({ + input: options.inputPath, + plugins: rollupPlugins, + }); + + const generated = await rollupBuild.generate({ + format: 'iife', + name: 'cc_modular', + sourcemap: true, + }); + + code = generated.code; + + console.log(`Doing uglify...`); + + const minifyOutput = minify(code, { + compress: { + global_defs: options.globalDefines, + }, + }); + if (minifyOutput.error) { + console.error(minifyOutput.error.stack); + return null; + } else { + code = minifyOutput.code; + } + + return { + code, + }; +} diff --git a/rollup/config.js b/rollup/config.js index fbead501ca..1bc59f2ff8 100644 --- a/rollup/config.js +++ b/rollup/config.js @@ -6,7 +6,7 @@ import commonjs from 'rollup-plugin-commonjs'; const dest = './bin'; const file = 'cocos-3d.dev'; -const moduleName = 'cocos3d'; +const moduleName = 'cc_modular'; fsJetpack.dir(dest); diff --git a/rollup/tsconfig.json b/rollup/tsconfig.json new file mode 100644 index 0000000000..505f79138c --- /dev/null +++ b/rollup/tsconfig.json @@ -0,0 +1,60 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./out", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file From 9520e3dc5d0c49c1578735c7a48438230823411b Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Fri, 11 Jan 2019 10:05:15 +0800 Subject: [PATCH 4/4] target display on camera-component --- cocos/3d/framework/camera-component.ts | 12 +--- cocos/3d/primitive/box.ts | 47 +++++++------- cocos/3d/primitive/defines.ts | 6 -- cocos/pipeline/render-view.ts | 18 +++--- cocos/renderer/scene/camera.ts | 39 ++++++------ playground/simple.html | 85 ++++++-------------------- 6 files changed, 80 insertions(+), 127 deletions(-) diff --git a/cocos/3d/framework/camera-component.ts b/cocos/3d/framework/camera-component.ts index e41313ff37..1ff29feb59 100644 --- a/cocos/3d/framework/camera-component.ts +++ b/cocos/3d/framework/camera-component.ts @@ -123,12 +123,7 @@ export class CameraComponent extends Component { set projection (val) { this._projection = val; - - let type = CameraProjection.PERSPECTIVE; - if (this._projection === ProjectionType.ORTHO) { - type = CameraProjection.ORTHO; - } - if (this._camera) { this._camera.projectionType = type; } + if (this._camera) { this._camera.projectionType = val; } } /** @@ -226,9 +221,7 @@ export class CameraComponent extends Component { set depth (val) { this._depth = val; - if (this._camera) { - this._camera.clearDepth = val; - } + if (this._camera) { this._camera.clearDepth = val; } } /** @@ -287,6 +280,7 @@ export class CameraComponent extends Component { } set targetDisplay (val) { this._targetDisplay = val; + if (this._camera) { this._camera.changeTargetDisplay(val); } } public onLoad () { diff --git a/cocos/3d/primitive/box.ts b/cocos/3d/primitive/box.ts index 8d4661e587..19e604581f 100644 --- a/cocos/3d/primitive/box.ts +++ b/cocos/3d/primitive/box.ts @@ -1,22 +1,23 @@ +import { Vec3 } from '../../core/value-types'; import { vec3 } from '../../core/vmath'; import { GFXPrimitiveMode } from '../../gfx/define'; -import { IGeometry, IGeometryOptions, normalizeGeometryOptions } from './defines'; +import { IGeometry, IGeometryOptions } from './defines'; interface IBoxOptions extends IGeometryOptions { /** * Box extent on X-axis. */ - width: number; + width?: number; /** * Box extent on Y-axis. */ - height: number; + height?: number; /** * Box extent on Z-axis. */ - length: number; + length?: number; /** * Segment count on X-axis. @@ -39,15 +40,15 @@ interface IBoxOptions extends IGeometryOptions { * but may emplaced through `center` option). * @param options Options. */ -export default function box (options: IBoxOptions): IGeometry { - normalizeGeometryOptions(options); +export default function box (options?: IBoxOptions): IGeometry { + options = options || {}; const ws = options.widthSegments || 1; const hs = options.heightSegments || 1; const ls = options.lengthSegments || 1; - const hw = options.width / 2; - const hh = options.height / 2; - const hl = options.length / 2; + const hw = (options.width || 1) / 2; + const hh = (options.height || 1) / 2; + const hl = (options.length || 1) / 2; const corners = [ vec3.set(c0, -hw, -hh, hl), @@ -82,8 +83,8 @@ export default function box (options: IBoxOptions): IGeometry { const normals: number[] = []; const uvs: number[] = []; const indices: number[] = []; - const minPos = vec3.create(-hw, -hh, -hl); - const maxPos = vec3.create(hw, hh, hl); + const minPos = new Vec3(-hw, -hh, -hl); + const maxPos = new Vec3(hw, hh, hl); const boundingRadius = Math.sqrt(hw * hw + hh * hh + hl * hl); function _buildPlane (side: number, uSegments: number, vSegments: number) { @@ -142,15 +143,15 @@ export default function box (options: IBoxOptions): IGeometry { }; } -const temp1 = vec3.create(0, 0, 0); -const temp2 = vec3.create(0, 0, 0); -const temp3 = vec3.create(0, 0, 0); -const r = vec3.create(0, 0, 0); -const c0 = vec3.create(0, 0, 0); -const c1 = vec3.create(0, 0, 0); -const c2 = vec3.create(0, 0, 0); -const c3 = vec3.create(0, 0, 0); -const c4 = vec3.create(0, 0, 0); -const c5 = vec3.create(0, 0, 0); -const c6 = vec3.create(0, 0, 0); -const c7 = vec3.create(0, 0, 0); +const temp1 = new Vec3(); +const temp2 = new Vec3(); +const temp3 = new Vec3(); +const r = new Vec3(); +const c0 = new Vec3(); +const c1 = new Vec3(); +const c2 = new Vec3(); +const c3 = new Vec3(); +const c4 = new Vec3(); +const c5 = new Vec3(); +const c6 = new Vec3(); +const c7 = new Vec3(); diff --git a/cocos/3d/primitive/defines.ts b/cocos/3d/primitive/defines.ts index c189b4c6d2..d6b6f43e20 100644 --- a/cocos/3d/primitive/defines.ts +++ b/cocos/3d/primitive/defines.ts @@ -7,12 +7,6 @@ export interface IGeometryOptions { includeNormal?: boolean; } -export function normalizeGeometryOptions (options: IGeometryOptions) { - options.includeNormal = options.includeNormal === undefined ? - true : options.includeNormal; - return options; -} - export interface IGeometry { /** * Topology of the geometry vertices. diff --git a/cocos/pipeline/render-view.ts b/cocos/pipeline/render-view.ts index 7f5978ca43..f413551b7f 100644 --- a/cocos/pipeline/render-view.ts +++ b/cocos/pipeline/render-view.ts @@ -15,30 +15,34 @@ export interface IRenderViewInfo { export class RenderView { - public get name (): string { + public get name () { return this._name; } - public get window (): GFXWindow | null { + public get window () { return this._window; } - public get priority (): number { + public set window (val) { + this._window = val; + } + + public get priority () { return this._priority; } - public set visibility (vis: number) { + public set visibility (vis) { this._visibility = vis; } - public get visibility (): number { + public get visibility () { return this._visibility; } - public get camera (): Camera { + public get camera () { return this._camera as Camera; } - public get scene (): RenderScene { + public get scene () { return this._scene as RenderScene; } diff --git a/cocos/renderer/scene/camera.ts b/cocos/renderer/scene/camera.ts index b7d61a63f3..22ede78912 100644 --- a/cocos/renderer/scene/camera.ts +++ b/cocos/renderer/scene/camera.ts @@ -73,23 +73,8 @@ export class Camera { this._clearStencil = info.stencil; this._clearFlag = info.clearFlags; - const win = scene.root.windows[info.targetDisplay - 1] || scene.root.mainWindow; - if (win) { - this._width = win.width; - this._height = win.height; - const view = this._view = scene.root.createView({ - name: `${name}View`, - window: win, - priority: RenderViewPriority.GENERAL, - }); - if (view) { view.attach(this); } - } else { - this._width = 1; - this._height = 1; - } - this._aspect = this._width / this._height; - - this._visibility = 0; + this._aspect = this._width = this._height = 1; + this.changeTargetDisplay(info.targetDisplay); } public resize (width: number, height: number) { @@ -282,6 +267,26 @@ export class Camera { return ray.fromPoints(out, v_b, v_a); } + public changeTargetDisplay (val: number) { + const scene = this._scene; + const win = scene.root.windows[val - 1] || scene.root.mainWindow; + if (win) { + this._width = win.width; + this._height = win.height; + if (!this._view) { + this._view = scene.root.createView({ + name: this._name, + window: win, + priority: RenderViewPriority.GENERAL, + }); + if (this._view) { this._view.attach(this); } + } else { + this._view.window = win; + } + } + this._aspect = this._width / this._height; + } + /** * transform a screen position to world space */ diff --git a/playground/simple.html b/playground/simple.html index af943961a5..6df1de6b94 100644 --- a/playground/simple.html +++ b/playground/simple.html @@ -28,8 +28,14 @@ -