diff --git a/.gitignore b/.gitignore index 070094f..03c3e8d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ npm-debug.log # Misc deploy_key -deploy_key.pub \ No newline at end of file +deploy_key.pub +.vscode/settings.json diff --git a/lib/SecurityDomain.ts b/lib/SecurityDomain.ts index 9d75429..5f0a11d 100644 --- a/lib/SecurityDomain.ts +++ b/lib/SecurityDomain.ts @@ -17,6 +17,7 @@ import { EventDispatcher } from './events/EventDispatcher'; import { DisplayObject } from './display/DisplayObject'; import { DisplayObjectContainer } from './display/DisplayObjectContainer'; import { Stage } from './display/Stage'; +import { Stage3D } from './display/Stage3D'; import { Loader } from './display/Loader'; import { LoaderInfo } from './display/LoaderInfo'; import { MovieClip } from './display/MovieClip'; @@ -74,6 +75,13 @@ import { ContextMenuItem } from './ui/ContextMenuItem'; import { FrameLabel } from './display/FrameLabel'; import { TextLineMetrics } from './text/TextLineMetrics'; import { FocusEvent } from './events/FocusEvent'; +import { Context3D } from './display3D/Context3D'; +import { IndexBuffer3D } from './display3D/IndexBuffer3D'; +import { Program3D } from './display3D/Program3D'; +import { VertexBuffer3D } from './display3D/VertexBuffer3D'; +import { TextureBase } from './display3D/textures/TextureBase'; +import { Texture } from './display3D/textures/Texture'; +import { CubeTexture } from './display3D/textures/CubeTexture'; export class Mouse {} @@ -84,6 +92,7 @@ export class SecurityDomain extends AXSecurityDomain { DisplayObject: DisplayObject, DisplayObjectContainer: DisplayObjectContainer, Stage: Stage, + Stage3D: Stage3D, Loader: Loader, LoaderInfo: LoaderInfo, MovieClip: MovieClip, @@ -95,6 +104,18 @@ export class SecurityDomain extends AXSecurityDomain { Shape: Shape, FrameLabel: FrameLabel }, + display3D: { + Context3D: Context3D, + IndexBuffer3D: IndexBuffer3D, + Program3D: Program3D, + VertexBuffer3D: VertexBuffer3D, + textures: { + TextureBase: TextureBase, + Texture: Texture, + RectangleTexture: Texture, + CubeTexture: CubeTexture, + } + }, events: { EventDispatcher: EventDispatcher, Event: Event, diff --git a/lib/display/LoaderInfo.ts b/lib/display/LoaderInfo.ts index b673679..44511c1 100644 --- a/lib/display/LoaderInfo.ts +++ b/lib/display/LoaderInfo.ts @@ -12,6 +12,7 @@ import { DisplayObject as AwayDisplayObject } from '@awayjs/scene'; import { SecurityDomain } from '../SecurityDomain'; import { PickGroup } from '@awayjs/view'; import { AVMStage } from '@awayfl/swf-loader'; +import { UncaughtErrorEvents } from '../events/UncaughtErrorEvents'; interface LoaderInfoCompleteQueueItem { loaderInfo: LoaderInfo; @@ -159,6 +160,7 @@ export class LoaderInfo extends EventDispatcher { private _swfVersion: number; private _applicationDomain: ApplicationDomain; + private _uncaughtErrorEvents: UncaughtErrorEvents; /** * The ActionScript version of the loaded SWF file. The language @@ -193,6 +195,7 @@ export class LoaderInfo extends EventDispatcher { constructor(loader: ILoader, container: AwayDisplayObject) { super(); + this._uncaughtErrorEvents; // Events that are supposed to be working are registered as eventMappingExtern: this.eventMappingExtern[Event.COMPLETE] = 'LoaderInfo:Event.COMPLETE'; @@ -639,7 +642,10 @@ export class LoaderInfo extends EventDispatcher { public get uncaughtErrorEvents(): any { // @todo Debug.throwPIR('playerglobals/display/LoaderInfo', 'get uncaughtErrorEvents', ''); - return null; + if (!this._uncaughtErrorEvents) + this._uncaughtErrorEvents = new UncaughtErrorEvents(); + + return this._uncaughtErrorEvents; } diff --git a/lib/display/Stage.ts b/lib/display/Stage.ts index f853575..b9bf776 100644 --- a/lib/display/Stage.ts +++ b/lib/display/Stage.ts @@ -6,7 +6,7 @@ import { DisplayObjectContainer } from './DisplayObjectContainer'; import { DisplayObject } from './DisplayObject'; import { FrameScriptManager } from '@awayjs/scene'; import { View } from '@awayjs/view'; -import { Stage as AwayStage } from '@awayjs/stage'; +import { Stage3D } from './Stage3D'; import { DisplayObjectContainer as AwayDisplayObjectContainer, MouseEvent as MouseEventAway } from '@awayjs/scene'; import { Transform } from '../geom/Transform'; import { Rectangle } from '../geom/Rectangle'; @@ -16,6 +16,8 @@ import { Loader as PlayerGlobalLoader } from './Loader'; import { LoaderInfo, LoaderInfoCompleteQueue } from './LoaderInfo'; import { Debug } from '@awayjs/core'; import { InteractiveObject } from './InteractiveObject'; +import { StageManager } from '@awayjs/stage'; +import { GenericVector } from '@awayfl/avm2'; /** * Dispatched by the Stage object when the state of the stageVideos property changes. @@ -153,7 +155,7 @@ import { InteractiveObject } from './InteractiveObject'; export class Stage extends DisplayObjectContainer { - private _stage3Ds: AwayStage[]; + private _stage3Ds: GenericVector; private _sendEventRender: boolean; @@ -162,7 +164,10 @@ export class Stage extends DisplayObjectContainer { this._isStage = true; - this._stage3Ds = []; + this._stage3Ds = new ( this.sec).ObjectVector(); + for (let i: number = 0; i < AVMStage.instance().stage3Ds.length; i++) { + this._stage3Ds.axSetNumericProperty(i, new ( this.sec).flash.display.Stage3D(i)); + } // resize event listens on window this._resizeCallbackDelegate = (event: any) => this.resizeCallback(event); @@ -476,7 +481,7 @@ export class Stage extends DisplayObjectContainer { public get contentsScaleFactor (): number { // @todo Debug.throwPIR('playerglobals/display/Stage', 'get contentsScaleFactor', ''); - return 0; + return 1; } public get displayContextInfo (): string { @@ -808,7 +813,7 @@ export class Stage extends DisplayObjectContainer { } - public get stage3Ds (): AwayStage[] { + public get stage3Ds (): GenericVector { // @todo Debug.throwPIR('playerglobals/display/Stage', 'get stage3Ds', ''); return this._stage3Ds; @@ -1143,4 +1148,4 @@ export class Stage extends DisplayObjectContainer { return false; } -} \ No newline at end of file +} diff --git a/lib/display/Stage3D.ts b/lib/display/Stage3D.ts new file mode 100644 index 0000000..db1df70 --- /dev/null +++ b/lib/display/Stage3D.ts @@ -0,0 +1,104 @@ +import { AVMStage } from '@awayfl/swf-loader'; +import { ContextGLProfile, Stage as AwayStage } from '@awayjs/stage'; +import { Context3D } from '../display3D/Context3D'; +import { Event } from '../events/Event'; +import { EventDispatcher } from '../events/EventDispatcher'; +import { SecurityDomain } from '../SecurityDomain'; +import { AXSecurityDomain } from '@awayfl/avm2'; +import { ErrorEvent } from '../events/ErrorEvent'; + +export class Stage3D extends EventDispatcher { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + // List of static symbols to link. + public static classSymbols: string[] = null; // []; + + // List of instance symbols to link. + public static instanceSymbols: string[] = null; // []; + private _context3D: Context3D + private _id: number + private _adaptee: AwayStage + + constructor(i) { + super(); + console.log('Stage3D Constructor'); + this._adaptee = AVMStage.instance().stage3Ds[i]; + this._id = i; + } + + public get adaptee(): AwayStage { + return this._adaptee; + } + + public get x(): number { + return this._adaptee.x; + } + + public set x(value: number) { + this._adaptee.y = value; + } + + public get y(): number { + return this._adaptee.y; + } + + public set y(value: number) { + this._adaptee.y = value; + } + + public get visible(): boolean { + return this._adaptee.visible ; + } + + public set visible(value: boolean) { + this._adaptee.visible = value; + } + + public get context3D(): Context3D { + return this._context3D; + } + + public requestContext3D(context3DRenderMode: string = 'auto', profile: string = 'baseline'): void { + const stage3D:Stage3D = this + setTimeout(function(){ + console.log('Request Context'); + stage3D._context3D = new (stage3D.sec as SecurityDomain).flash.display3D.Context3D(stage3D._id, stage3D, profile, context3DRenderMode); + const forceSoftware: boolean = (context3DRenderMode == 'software'); + var awayContextProfile: ContextGLProfile; + switch (profile) { + case 'baseline': + awayContextProfile = ContextGLProfile.BASELINE; + break; + case 'baseline_constrained': + awayContextProfile = ContextGLProfile.BASELINE_CONSTRAINED; + break; + case 'baseline_extended': + awayContextProfile = ContextGLProfile.BASELINE_EXTENDED; + break; + case 'standard': + awayContextProfile = ContextGLProfile.STANDARD; + break; + case 'standard_constrained': + awayContextProfile = ContextGLProfile.STANDARD_CONSTRAINED; + break; + case 'standard_extended': + awayContextProfile = ContextGLProfile.STANDARD_EXTENDED; + break; + case 'enhanced': + awayContextProfile = ContextGLProfile.ENHANCED; + break; + default: + break; + } + console.log('Context3D Config: ', 'id: ', stage3D._id, ' forceSoftware: ', forceSoftware, ' profile: ', awayContextProfile); + + function dispatchContextCreated(e:Event){ + console.log(stage3D.context3D.driverInfo) + stage3D._context3D.removeEventListener(Event.CONTEXT3D_CREATE, dispatchContextCreated) + stage3D.dispatchEvent(new (stage3D.sec).flash.events.Event(Event.CONTEXT3D_CREATE)); + } + stage3D._context3D.addEventListener(Event.CONTEXT3D_CREATE, dispatchContextCreated) + stage3D._adaptee.requestContext(forceSoftware, awayContextProfile);},1) + } +} \ No newline at end of file diff --git a/lib/display3D/Context3D.ts b/lib/display3D/Context3D.ts index 882b07c..834941e 100644 --- a/lib/display3D/Context3D.ts +++ b/lib/display3D/Context3D.ts @@ -1 +1,275 @@ -export { ContextWebGL as Context3D } from '@awayjs/stage'; +import { BitmapImage2D, ContextGLDrawMode, ContextGLProfile, ContextGLProgramType, ContextGLVertexBufferFormat, ContextWebGL, IVertexBuffer, ProgramWebGL, Stage as AwayStage, StageEvent, TextureWebGL } from '@awayjs/stage'; +import { BitmapData } from '../display/BitmapData'; +import { Stage3D } from '../display/Stage3D'; +import { Context3DProgramType } from '../display3D/Context3DProgramType'; +import { Context3DVertexBufferFormat } from '../display3D/Context3DVertexBufferFormat'; +import { IndexBuffer3D } from '../display3D/IndexBuffer3D'; +import { Program3D } from '../display3D/Program3D'; +import { VertexBuffer3D } from '../display3D/VertexBuffer3D'; +import { EventDispatcher } from '../events/EventDispatcher'; +import { Matrix3D } from '../geom/Matrix3D'; +import { Rectangle } from '../geom/Rectangle'; +import { ByteArray } from '../utils/ByteArray'; +import { axCoerceString, Float64Vector } from '@awayfl/avm2'; +import { Debug } from '@awayfl/swf-loader'; +import { SecurityDomain } from '../SecurityDomain'; +import { Event } from '../events/Event'; +import { Security } from '../system/Security'; +import { Texture } from './textures/Texture'; +import { CubeTexture } from './textures/CubeTexture'; +import { TextureBase } from './textures/TextureBase'; +import { VertexBufferWebGL } from '@awayjs/stage'; + +export class Context3D extends EventDispatcher { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + // List of static symbols to link. + public static classSymbols: string[] = null; // []; + + // List of instance symbols to link. + public static instanceSymbols: string[] = null; // []; + + private _adaptee: AwayStage + private _profile: string + private _gl: WebGL2RenderingContext | WebGLRenderingContext + //private _currentProgram : Program3D + + constructor(id: number, stage3D: Stage3D, renderMode: string = 'auto', profile: string = 'baseline') { + super(); + const context3D:Context3D = this + const thisSec:SecurityDomain = (this.sec as SecurityDomain); + + console.log(`Context3D Create: ${renderMode} ${profile}`); + this._profile = profile; + this._adaptee = stage3D.adaptee; + function dispatchContextCreated(e:StageEvent){ + context3D.adaptee.removeEventListener(StageEvent.CONTEXT_RECREATED, dispatchContextCreated) + context3D.dispatchEvent(new thisSec.flash.events.Event(Event.CONTEXT3D_CREATE)); + context3D._gl = (context3D.adaptee.context)._gl + } + this._adaptee.addEventListener(StageEvent.CONTEXT_RECREATED, dispatchContextCreated) + } + + public get adaptee(): AwayStage { + return this._adaptee; + } + + public get backBufferHeight(): number { + return this._adaptee.height + } + + public get backBufferWidth(): number { + return this._adaptee.width + } + + public get driverInfo(): string { + Debug.notImplemented('public flash.display3D.Context3D::get driverInfo'); + return 'OpenGL'; + } + + public get enableErrorChecking(): boolean { + Debug.notImplemented('public flash.display3D.Context3D::get enableErrorChecking'); + return false + } + + public set enableErrorChecking(toggle: boolean) { + toggle = !!toggle; + Debug.notImplemented('public flash.display3D.Context3D::set enableErrorChecking'); return; + // this._enableErrorChecking = toggle; + } + + public get maxBackBufferWidth(): number { + Debug.notImplemented('public flash.display3D.Context3D::get maxBackBufferWidth'); + return 2048; + } + + public set maxBackBufferWidth(value: number) { + Debug.notImplemented('public flash.display3D.Context3D::set maxBackBufferWidth'); + } + + public get maxBackBufferHeight(): number { + Debug.notImplemented('public flash.display3D.Context3D::set maxBackBufferHeight'); + return 2048; + } + + public set maxBackBufferHeight(value: number) { + Debug.notImplemented('public flash.display3D.Context3D::set maxBackBufferHeight'); + } + + public get profile(): string { + Debug.notImplemented('public flash.display3D.Context3D::get profile'); + return axCoerceString(this._profile); + } + + public static get supportsVideoTexture(): boolean { + Debug.notImplemented('public flash.display3D.Context3D::get driverInfo'); + return false;; + } + + public get totalGPUMemory(): number { + Debug.notImplemented('public flash.display3D.Context3D::get totalGPUMemory'); + return 1024;; + } + + public dispose(): void { + this._adaptee.context.dispose(); + } + + public configureBackBuffer(width: number, height: number, antiAlias: number, enableDepthAndStencil: boolean = true, wantsBestResolution: boolean = false, wantsBestResolutionOnBrowserZoom: boolean = false): void { + this._adaptee.configureBackBuffer(width, height, antiAlias, enableDepthAndStencil); + } + + public clear(red: number = 0.0, green: number = 0.0, blue: number = 0.0, alpha: number = 1.0, depth: number = 1.0, stencil: number = 0, mask: number = 0xffffffff): void { + this._adaptee.clear(red, green, blue, alpha, depth, stencil, mask); + } + + public drawTriangles(indexBuffer: IndexBuffer3D, firstIndex: number = 0, numTriangles: number = -1): void { + this._adaptee.context.drawIndices(ContextGLDrawMode.TRIANGLES, indexBuffer._adaptee, firstIndex, (numTriangles == -1) ? -1 : (numTriangles * 3)); + } + + public present(): void { + this._adaptee.present(); + } + + public setProgram(program: Program3D): void { + this._adaptee.context.setProgram(program._adaptee); + //this._currentProgram = program + } + + public setProgramConstantsFromVector(programType: string, firstRegister: number /*int*/, data: Float64Vector, numRegisters: number /*int*/ = -1): void { + let awayProgramType: ContextGLProgramType; + switch (programType) { + case Context3DProgramType.FRAGMENT: + awayProgramType = ContextGLProgramType.FRAGMENT; + break; + case Context3DProgramType.VERTEX: + awayProgramType = ContextGLProgramType.VERTEX; + break; + default: + break; + } + // @todo: support transposed matrixes + let awayData:Float32Array = new Float32Array(data.length) + for(let i = 0; i < data.length; i++) { + awayData[i] = data.axGetNumericProperty(i) + + } + this._adaptee.context.setProgramConstantsFromArray(awayProgramType, awayData); + } + + public setProgramConstantsFromMatrix(programType: string, firstRegister: number, matrix: Matrix3D, transposedMatrix: boolean = false): void { + let awayProgramType: ContextGLProgramType; + switch (programType) { + case Context3DProgramType.FRAGMENT: + awayProgramType = ContextGLProgramType.FRAGMENT; + break; + case Context3DProgramType.VERTEX: + awayProgramType = ContextGLProgramType.VERTEX; + break; + default: + break; + } + // @todo: support transposed matrixes + this._adaptee.context.setProgramConstantsFromArray(awayProgramType, matrix.adaptee._rawData); + } + + public setProgramConstantsFromByteArray(programType: string, firstRegister: number /*int*/, numRegisters: number /*int*/, data: ByteArray, byteArrayOffset: number /*uint*/): void { + Debug.notImplemented('public flash.display3D.Context3D::setProgramConstantsFromByteArray'); return; + } + + public setVertexBufferAt(index: number, buffer: VertexBuffer3D, bufferOffset: number = 0, format: string = 'float4'): void { + let awayFormat: number; + switch (format) { + case Context3DVertexBufferFormat.BYTES_4: + awayFormat = ContextGLVertexBufferFormat.BYTE_4; + break; + case Context3DVertexBufferFormat.FLOAT_1: + awayFormat = ContextGLVertexBufferFormat.FLOAT_1; + break; + case Context3DVertexBufferFormat.FLOAT_2: + awayFormat = ContextGLVertexBufferFormat.FLOAT_2; + break; + case Context3DVertexBufferFormat.FLOAT_3: + awayFormat = ContextGLVertexBufferFormat.FLOAT_3; + break; + case Context3DVertexBufferFormat.FLOAT_4: + awayFormat = ContextGLVertexBufferFormat.FLOAT_4; + break; + default: + break; + } + (this._adaptee.context).setVertexBufferAt( buffer ? index : -1, buffer ? buffer._adaptee : null, bufferOffset * 4, awayFormat, false); + + } + + public setBlendFactors(sourceFactor: string, destinationFactor: string): void { + Debug.notImplemented('public flash.display3D.Context3D::setBlendFactors'); return; + } + + public setColorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void { + Debug.notImplemented('public flash.display3D.Context3D::setColorMask'); return; + } + + public setDepthTest(fdepthMask: boolean, passCompareMode: string): void { + Debug.notImplemented('public flash.display3D.Context3D::setDepthTest'); return; + } + + public setCulling(triangleFaceToCull: string): void { + Debug.notImplemented('public flash.display3D.Context3D::setCulling'); return; + } + + public setStencilActions(triangleFace: string = 'frontAndBack', compareMode: string = 'always', actionOnBothPass: string = 'keep', actionOnDepthFail: string = 'keep', actionOnDepthPassStencilFail: string = 'keep'): void { + Debug.notImplemented('public flash.display3D.Context3D::setStencilActions'); return; + } + + public setStencilReferenceValue(referenceValue: number /*uint*/, readMask: number /*uint*/ = 255, writeMask: number /*uint*/ = 255): void { + Debug.notImplemented('public flash.display3D.Context3D::setStencilReferenceValue'); return; + } + + public setScissorRectangle(rectangle: Rectangle): void { + Debug.notImplemented('public flash.display3D.Context3D::setScissorRectangle'); return; + } + + public createVertexBuffer(numVertices: number, data32PerVertex: number, bufferUsage: string = 'staticDraw'): VertexBuffer3D { + console.log('createVertexBuffer'); + return new (this.sec as SecurityDomain).flash.display3D.VertexBuffer3D(this, numVertices, data32PerVertex); + } + + public createIndexBuffer(numIndices: number, bufferUsage: string = 'staticDraw'): IndexBuffer3D { + return new (this.sec as SecurityDomain).flash.display3D.IndexBuffer3D(this, numIndices); + } + + public createTexture(width: number /*int*/, height: number /*int*/, format: string, optimizeForRenderToTexture: boolean, streamingLevels: number /*int*/ = 0): any { + return new (this.sec as SecurityDomain).flash.display3D.textures.Texture(this, width, height, format, optimizeForRenderToTexture, streamingLevels); + } + + public createRectangleTexture(width: number /*int*/, height: number /*int*/, format: string, optimizeForRenderToTexture: boolean): any { + return new (this.sec as SecurityDomain).flash.display3D.textures.RectangleTexture(this, width, height, format, optimizeForRenderToTexture); + } + + public createCubeTexture(size: number /*int*/, format: string, optimizeForRenderToTexture: boolean, streamingLevels: number /*int*/ = 0): any /*CubeTexture*/ { + return new (this.sec as SecurityDomain).flash.display3D.textures.CubeTexture(this, size, format, optimizeForRenderToTexture, streamingLevels) + } + + public createProgram(): Program3D { + return new (this.sec as SecurityDomain).flash.display3D.Program3D(this); + } + + public drawToBitmapData(destination: BitmapData): void { + this.adaptee.context.drawToBitmapImage2D(destination.adaptee as any as BitmapImage2D); + } + + public setRenderToBackBuffer() { + this._adaptee.context.setRenderToBackBuffer(); + } + + public setRenderToTexture(texture:TextureBase, targetType: number /*int*/, enableDepthAndStencil: boolean, antiAlias: number /*int*/, surfaceSelector: number /*int*/): void { + this._adaptee.context.setRenderToTexture(texture._adaptee, enableDepthAndStencil, antiAlias, surfaceSelector) + } + + public setTextureAt(sampler: number /*int*/, texture:TextureBase): void { + if(texture) + this._adaptee.context.setTextureAt(sampler, texture._adaptee) + } +} \ No newline at end of file diff --git a/lib/display3D/Context3DBlendFactor.ts b/lib/display3D/Context3DBlendFactor.ts new file mode 100644 index 0000000..27e78a9 --- /dev/null +++ b/lib/display3D/Context3DBlendFactor.ts @@ -0,0 +1,43 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ASObject } from '@awayfl/avm2'; + +// Class: Context3DBlendFactor +export class Context3DBlendFactor extends ASObject { + + // Called whenever the class is initialized. + public static classInitializer: any = null; + + constructor () { + super(); + } + + // JS -> AS Bindings + public static ONE: string = 'one'; + public static ZERO: string = 'zero'; + public static SOURCE_ALPHA: string = 'sourceAlpha'; + public static SOURCE_COLOR: string = 'sourceColor'; + public static ONE_MINUS_SOURCE_ALPHA: string = 'oneMinusSourceAlpha'; + public static ONE_MINUS_SOURCE_COLOR: string = 'oneMinusSourceColor'; + public static DESTINATION_ALPHA: string = 'destinationAlpha'; + public static DESTINATION_COLOR: string = 'destinationColor'; + public static ONE_MINUS_DESTINATION_ALPHA: string = 'oneMinusDestinationAlpha'; + public static ONE_MINUS_DESTINATION_COLOR: string = 'oneMinusDestinationColor'; + + // AS -> JS Bindings + +} diff --git a/lib/display3D/Context3DClearMask.ts b/lib/display3D/Context3DClearMask.ts index 73d8f6f..a6c0aa9 100644 --- a/lib/display3D/Context3DClearMask.ts +++ b/lib/display3D/Context3DClearMask.ts @@ -1 +1,20 @@ -export { ContextGLClearMask as Context3DClearMask } from '@awayjs/stage'; +import { ASObject } from '@awayfl/avm2'; + +// Based on https://github.com/ruffle-rs/ruffle/blob/master/core/src/avm2/globals/flash/display3D/Context3DClearMask.as +export class Context3DClearMask extends ASObject { + + // Called whenever the class is initialized. + public static classInitializer: any = null; + + // Clear only the color buffer. + public static COLOR: number = 1 << 0; + + // Clear only the depth buffer. + public static DEPTH: number = 1 << 1; + + // Clear only the stencil buffer. + public static STENCIL: number = 1 << 2; + + // Clear all buffers. + public static ALL: number = Context3DClearMask.COLOR | Context3DClearMask.DEPTH | Context3DClearMask.STENCIL; +} \ No newline at end of file diff --git a/lib/display3D/Context3DCompareMode.ts b/lib/display3D/Context3DCompareMode.ts new file mode 100644 index 0000000..e5063d0 --- /dev/null +++ b/lib/display3D/Context3DCompareMode.ts @@ -0,0 +1,41 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ASObject } from "@awayfl/avm2"; + + export class Context3DCompareMode extends ASObject { + + // Called whenever the class is initialized. + static classInitializer: any = null; + + constructor () { + super(); + } + + // JS -> AS Bindings + static ALWAYS: string = 'always'; + static NEVER: string = 'never'; + static LESS: string = 'less'; + static LESS_EQUAL: string = 'lessEqual'; + static EQUAL: string = 'equal'; + static GREATER_EQUAL: string = 'greaterEqual'; + static GREATER: string = 'greater'; + static NOT_EQUAL: string = 'notEqual'; + + // AS -> JS Bindings + + } + diff --git a/lib/display3D/Context3DProfile.ts b/lib/display3D/Context3DProfile.ts new file mode 100644 index 0000000..6c1f62b --- /dev/null +++ b/lib/display3D/Context3DProfile.ts @@ -0,0 +1,13 @@ +import { ASObject } from '@awayfl/avm2'; + +export class Context3DProfile extends ASObject { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + public static BASELINE: string = 'baseline'; + public static BASELINE_CONSTRAINED: string = 'baselineConstrained'; + public static BASELINE_EXTENDED: string = 'baselineExtended'; + public static STANDARD: string = 'standard'; + public static STANDARD_CONSTRAINED: string = 'standardConstrained'; + public static STANDARD_EXTENDED: string = 'standardExtended'; +} \ No newline at end of file diff --git a/lib/display3D/Context3DProgramType.ts b/lib/display3D/Context3DProgramType.ts index 325b76b..d59de96 100644 --- a/lib/display3D/Context3DProgramType.ts +++ b/lib/display3D/Context3DProgramType.ts @@ -1 +1,9 @@ -export { ContextGLProgramType as Context3DProgramType } from '@awayjs/stage'; +import { ASObject } from '@awayfl/avm2'; + +export class Context3DProgramType extends ASObject { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + public static FRAGMENT: string = 'fragment'; + public static VERTEX = 'vertex'; +} \ No newline at end of file diff --git a/lib/display3D/Context3DRenderMode.ts b/lib/display3D/Context3DRenderMode.ts new file mode 100644 index 0000000..c0e4537 --- /dev/null +++ b/lib/display3D/Context3DRenderMode.ts @@ -0,0 +1,9 @@ +import { ASObject } from '@awayfl/avm2'; + +export class Context3DRenderMode extends ASObject { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + public static AUTO: string = 'auto'; + public static SOFTWARE: string = 'software'; +} \ No newline at end of file diff --git a/lib/display3D/Context3DStencilAction.ts b/lib/display3D/Context3DStencilAction.ts new file mode 100644 index 0000000..90576f5 --- /dev/null +++ b/lib/display3D/Context3DStencilAction.ts @@ -0,0 +1,41 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ASObject } from "@awayfl/avm2"; + +// Class: Context3DStencilAction +export class Context3DStencilAction extends ASObject { + + // Called whenever the class is initialized. + static classInitializer: any = null; + + constructor () { + super(); + } + + // JS -> AS Bindings + static KEEP: string = 'keep'; + static ZERO: string = 'zero'; + static INCREMENT_SATURATE: string = 'incrementSaturate'; + static DECREMENT_SATURATE: string = 'decrementSaturate'; + static INVERT: string = 'invert'; + static INCREMENT_WRAP: string = 'incrementWrap'; + static DECREMENT_WRAP: string = 'decrementWrap'; + static SET: string = 'set'; + + // AS -> JS Bindings + + } diff --git a/lib/display3D/Context3DTextureFormat.ts b/lib/display3D/Context3DTextureFormat.ts new file mode 100644 index 0000000..7390d29 --- /dev/null +++ b/lib/display3D/Context3DTextureFormat.ts @@ -0,0 +1,35 @@ +import { ASObject } from "@awayfl/avm2"; + +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + export class Context3DTextureFormat extends ASObject { + + // Called whenever the class is initialized. + static classInitializer: any = null; + + constructor () { + super(); + } + + // JS -> AS Bindings + static BGRA: string = 'bgra'; + static COMPRESSED: string = 'compressed'; + static COMPRESSED_ALPHA: string = 'compressedAlpha'; + + // AS -> JS Bindings + + } + diff --git a/lib/display3D/Context3DTriangleFace.ts b/lib/display3D/Context3DTriangleFace.ts new file mode 100644 index 0000000..d6d3d7b --- /dev/null +++ b/lib/display3D/Context3DTriangleFace.ts @@ -0,0 +1,37 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Class: Context3DTriangleFace + +import { ASObject } from "@awayfl/avm2"; + + export class Context3DTriangleFace extends ASObject { + + // Called whenever the class is initialized. + static classInitializer: any = null; + + constructor () { + super(); + } + + // JS -> AS Bindings + static NONE: string = 'none'; + static BACK: string = 'back'; + static FRONT: string = 'front'; + static FRONT_AND_BACK: string = 'frontAndBack'; + + // AS -> JS Bindings + + } diff --git a/lib/display3D/Context3DVertexBufferFormat.ts b/lib/display3D/Context3DVertexBufferFormat.ts new file mode 100644 index 0000000..f5d1e82 --- /dev/null +++ b/lib/display3D/Context3DVertexBufferFormat.ts @@ -0,0 +1,12 @@ +import { ASObject } from '@awayfl/avm2'; + +export class Context3DVertexBufferFormat extends ASObject { + // Called whenever the class is initialized. + public static classInitializer: any = null; + + public static BYTES_4: string = 'bytes4'; + public static FLOAT_1: string = 'float1'; + public static FLOAT_2: string = 'float2'; + public static FLOAT_3: string = 'float3'; + public static FLOAT_4: string = 'float4'; +} \ No newline at end of file diff --git a/lib/display3D/IndexBuffer3D.ts b/lib/display3D/IndexBuffer3D.ts new file mode 100644 index 0000000..f69b216 --- /dev/null +++ b/lib/display3D/IndexBuffer3D.ts @@ -0,0 +1,36 @@ +import { ASObject, AXClass, Uint32Vector } from '@awayfl/avm2'; +import { Debug } from '@awayfl/swf-loader'; +import { IIndexBuffer } from '@awayjs/stage'; +import { ByteArray } from '../utils/ByteArray'; +import { Context3D } from './Context3D'; + +export class IndexBuffer3D extends ASObject { + static axClass: typeof IndexBuffer3D & AXClass; + static classInitializer: any = null; + static classSymbols: string [] = null; // []; + static instanceSymbols: string [] = null; + + public _adaptee: IIndexBuffer + + constructor(context3D: Context3D, numIndices: number) { + super(); + this._adaptee = context3D.adaptee.context.createIndexBuffer(numIndices); + } + + public uploadFromVector(data: Uint32Vector, startOffset: number, count: number): void { + const uint16ArrayData = new Uint16Array(data.length); + for (let i: number = 0; i < data.length; i++) { + uint16ArrayData[i] = data.axGetNumericProperty(i); + } + this._adaptee.uploadFromArray(uint16ArrayData, startOffset, count); + } + + public uploadFromByteArray(data: ByteArray, byteArrayOffset: number /*int*/, startOffset: number /*int*/, count: number /*int*/): void { + Debug.notImplemented('public flash.display3D.IndexBuffer3D::uploadFromByteArray'); return; + } + + public dispose(): void { + this._adaptee.dispose(); + } + +} \ No newline at end of file diff --git a/lib/display3D/Program3D.ts b/lib/display3D/Program3D.ts new file mode 100644 index 0000000..6a342f4 --- /dev/null +++ b/lib/display3D/Program3D.ts @@ -0,0 +1,28 @@ +import { ASObject, AXClass } from '@awayfl/avm2'; +import { IContextGL, IProgram } from '@awayjs/stage'; +import { ByteArray } from '../utils/ByteArray'; +import { Context3D } from './Context3D'; + +export class Program3D extends ASObject { + static axClass: typeof Program3D & AXClass; + static classInitializer: any = null; + static classSymbols: string [] = null; // []; + static instanceSymbols: string [] = null; + + public _adaptee: IProgram + private _context: IContextGL + + constructor(context3D: Context3D) { + super(); + this._context = context3D.adaptee.context; + this._adaptee = context3D.adaptee.context.createProgram(); + } + + public dispose() { + this._adaptee.dispose(); + } + + public upload(vertexProgram: ByteArray, fragmentProgram: ByteArray): void { + this._adaptee.upload(vertexProgram, fragmentProgram); + } +} \ No newline at end of file diff --git a/lib/display3D/Texture.ts b/lib/display3D/Texture.ts deleted file mode 100644 index be3d101..0000000 --- a/lib/display3D/Texture.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { BitmapData } from './../display/BitmapData'; -import { ByteArray } from './../utils/ByteArray'; -export class Texture { - - // todo. can probably route directly to awayjs class - - public static fromBitmapData(bitmapData: BitmapData): Texture { - console.warn('[playerglobal/display3D/Texture] - fromBitmapData not implemented'); - return null; - } - - constructor () { - } - - public uploadCompressedTextureFromByteArray (data: ByteArray, byteArrayOffset: number, async: boolean = false) { - console.warn('[playerglobal/display3D/Texture] - uploadCompressedTextureFromByteArray not implemented'); - - } - - public uploadFromBitmapData (source: BitmapData, miplevel: number = 0) { - console.warn('[playerglobal/display3D/Texture] - uploadFromBitmapData not implemented'); - - } - - public uploadFromByteArray (data: ByteArray, byteArrayOffset: number, miplevel: number = 0) { - console.warn('[playerglobal/display3D/Texture] - uploadFromByteArray not implemented'); - - } -} diff --git a/lib/display3D/VertexBuffer3D.ts b/lib/display3D/VertexBuffer3D.ts new file mode 100644 index 0000000..f4b5119 --- /dev/null +++ b/lib/display3D/VertexBuffer3D.ts @@ -0,0 +1,34 @@ +import { ASObject, AXClass, Float64Vector } from '@awayfl/avm2'; +import { Debug } from '@awayfl/swf-loader'; +import { IVertexBuffer } from '@awayjs/stage'; +import { ByteArray } from '../utils/ByteArray'; +import { Context3D } from './Context3D'; + +export class VertexBuffer3D extends ASObject { + static axClass: typeof VertexBuffer3D & AXClass; + static classInitializer: any = null; + static classSymbols: string [] = null; // []; + static instanceSymbols: string [] = null; + public _adaptee: IVertexBuffer + + constructor(context3D: Context3D, numVertices: number, data32PerVertex: number) { + super(); + this._adaptee = context3D.adaptee.context.createVertexBuffer(numVertices, data32PerVertex * 4); + } + + public uploadFromVector(data: Float64Vector, startVertex: number, numVertices) { + const dataFloat32Array: Float32Array = new Float32Array(data.length); + for (let i: number = 0; i < data.length; i++) { + dataFloat32Array[i] = data.axGetNumericProperty(i); + } + this._adaptee.uploadFromArray(dataFloat32Array, startVertex, numVertices); + } + + public uploadFromByteArray(data: ByteArray, byteArrayOffset: number /*int*/, startVertex: number /*int*/, numVertices: number /*int*/): void { + Debug.notImplemented('public flash.display3D.VertexBuffer3D::uploadFromByteArray'); return; + } + + public dispose(): void { + this._adaptee.dispose(); + } +} \ No newline at end of file diff --git a/lib/display3D/textures/CubeTexture.ts b/lib/display3D/textures/CubeTexture.ts new file mode 100644 index 0000000..216d70e --- /dev/null +++ b/lib/display3D/textures/CubeTexture.ts @@ -0,0 +1,75 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Class: CubeTexture +import { Debug } from "@awayfl/swf-loader"; +import { ContextGLTextureFormat, CubeTextureWebGL, TextureWebGL } from "@awayjs/stage"; +import { Context3D } from "../Context3D"; +import { BitmapData } from "./../../display/BitmapData"; +import { ByteArray } from "./../../utils/ByteArray"; +import { TextureBase } from "./TextureBase"; + +export class CubeTexture extends TextureBase { + // Called whenever the class is initialized. + static classInitializer: any = null; + + constructor( + context: Context3D, + size: number, + format: String, + optimizeForRenderToTexture: boolean, + streamingLevels: number = 0 + ) { + super(); + let awayTextureFormat: ContextGLTextureFormat; + switch (format) { + case "bgra": + awayTextureFormat = ContextGLTextureFormat.BGRA; + break; + case "compressed": + awayTextureFormat = ContextGLTextureFormat.COMPRESSED; + break; + case "compressedAlpha": + awayTextureFormat = ContextGLTextureFormat.COMPRESSED_ALPHA; + break; + } + this._adaptee = context.adaptee.context.createCubeTexture( + size, + awayTextureFormat, + optimizeForRenderToTexture, + streamingLevels + ) as CubeTextureWebGL; + } + + public uploadFromBitmapData(source: BitmapData, side: number /*uint*/, miplevel: number /*uint*/ = 0): void { + if(miplevel==0) // @todo: Additional Mips cause errors + (this._adaptee).uploadFromArray(new Uint8Array(source.adaptee.getDataInternal()), side, miplevel) + } + + public uploadFromByteArray(data: ByteArray,byteArrayOffset: number /*uint*/,side: number /*uint*/,miplevel: number /*uint*/ = 0 + ): void { + if(miplevel==0) // @todo: Additional Mips cause errors + (this._adaptee).uploadFromArray(new Uint8Array(data.arraybytes), side, miplevel) + } + + public uploadCompressedTextureFromByteArray(data: ByteArray,byteArrayOffset: number /*uint*/,async: boolean = false + ): void { + data = data; + byteArrayOffset = byteArrayOffset >>> 0; + async = !!async; + Debug.notImplemented("public flash.display3D.textures.CubeTexture::uploadCompressedTextureFromByteArray"); + return; + } +} diff --git a/lib/display3D/textures/Texture.ts b/lib/display3D/textures/Texture.ts new file mode 100644 index 0000000..56f104f --- /dev/null +++ b/lib/display3D/textures/Texture.ts @@ -0,0 +1,50 @@ +import { Debug } from "@awayfl/swf-loader"; +import { ContextGLTextureFormat, TextureWebGL } from "@awayjs/stage"; +import { Context3D } from "../Context3D"; +import { BitmapData } from "./../../display/BitmapData"; +import { ByteArray } from "./../../utils/ByteArray"; +import { TextureBase } from "./TextureBase"; +export class Texture extends TextureBase { + constructor( + context: Context3D, + width: number, + height: number, + format: string, + optimizeForRenderToTexture: boolean, + streamingLevels: number = 0 + ) { + super(); + let awayTextureFormat: ContextGLTextureFormat; + switch (format) { + case "bgra": + awayTextureFormat = ContextGLTextureFormat.BGRA; + break; + case "compressed": + awayTextureFormat = ContextGLTextureFormat.COMPRESSED; + break; + case "compressedAlpha": + awayTextureFormat = ContextGLTextureFormat.COMPRESSED_ALPHA; + break; + } + this._adaptee = context.adaptee.context.createTexture( + width, + height, + awayTextureFormat, + optimizeForRenderToTexture + ) as TextureWebGL; + } + + public uploadCompressedTextureFromByteArray(data: ByteArray, byteArrayOffset: number, async: boolean = false) { + Debug.notImplemented("public flash.display3D.textures.Texture::uploadCompressedTextureFromByteArray"); + } + + public uploadFromBitmapData(source: BitmapData, miplevel: number = 0) { + if(miplevel==0) // @todo: Additional Mips cause errors + (this._adaptee).uploadFromArray(new Uint8Array(source.adaptee.getDataInternal()), miplevel); + } + + public uploadFromByteArray(data: ByteArray, byteArrayOffset: number, miplevel: number = 0) { + if(miplevel==0) // @todo: Additional Mips cause errors + (this._adaptee).uploadFromArray(new Uint8Array(data.arraybytes), miplevel); + } +} diff --git a/lib/display3D/textures/TextureBase.ts b/lib/display3D/textures/TextureBase.ts new file mode 100644 index 0000000..574d58f --- /dev/null +++ b/lib/display3D/textures/TextureBase.ts @@ -0,0 +1,35 @@ +/** + * Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Debug } from '@awayfl/swf-loader'; +import { CubeTextureWebGL, TextureBaseWebGL, TextureWebGL } from '@awayjs/stage'; +import { EventDispatcher } from '../../events/EventDispatcher'; +import { CubeTexture } from './CubeTexture'; +import { Texture } from './Texture'; + +export class TextureBase extends EventDispatcher { + + // Called whenever the class is initialized. + static classInitializer: any = null; + public _adaptee: TextureBaseWebGL; + constructor () { + super(); + } + + public dispose(): void { + this._adaptee.dispose(); + } +} diff --git a/lib/geom/Matrix3D.ts b/lib/geom/Matrix3D.ts index 3376dfd..5fe89bc 100644 --- a/lib/geom/Matrix3D.ts +++ b/lib/geom/Matrix3D.ts @@ -142,7 +142,7 @@ export class Matrix3D extends ASObject { } public transformVector(v: Vector3D): Vector3D { - return new ( this.sec).flash.geom.Vector3D(this._adaptee.transformVector(v.adaptee, null, true)); + return new ( this.sec).flash.geom.Vector3D(this._adaptee.transformVector(v.adaptee)); } public deltaTransformVector(v: Vector3D): Vector3D { diff --git a/lib/link.ts b/lib/link.ts index 48e3836..9a959bf 100644 --- a/lib/link.ts +++ b/lib/link.ts @@ -25,6 +25,26 @@ import { Shape } from './display/Shape'; import { SimpleButton } from './display/SimpleButton'; import { Sprite } from './display/Sprite'; import { Stage } from './display/Stage'; +import { Stage3D } from './display/Stage3D'; + +import { Context3D } from './display3D/Context3D'; +import { Context3DBlendFactor } from './display3D/Context3DBlendFactor'; +import { Context3DClearMask } from './display3D/Context3DClearMask'; +import { Context3DCompareMode } from './display3D/Context3DCompareMode'; +import { Context3DProfile } from './display3D/Context3DProfile'; +import { Context3DProgramType } from './display3D/Context3DProgramType'; +import { Context3DRenderMode } from './display3D/Context3DRenderMode'; +import { Context3DStencilAction } from './display3D/Context3DStencilAction'; +import { Context3DTextureFormat } from './display3D/Context3DTextureFormat'; +import { Context3DTriangleFace } from './display3D/Context3DTriangleFace'; +import { Context3DVertexBufferFormat } from './display3D/Context3DVertexBufferFormat'; +import { IndexBuffer3D } from './display3D/IndexBuffer3D'; +import { Program3D } from './display3D/Program3D'; +import { VertexBuffer3D } from './display3D/VertexBuffer3D'; + +import { CubeTexture } from './display3D/textures/CubeTexture'; +import { Texture } from './display3D/textures/Texture'; +import { TextureBase } from './display3D/textures/TextureBase'; import { EOFError } from './errors/EOFError'; import { IllegalOperationError } from './errors/IllegalOperationError'; @@ -50,8 +70,8 @@ import { AsyncErrorEvent } from './events/AsyncErrorEvent'; import { ContextMenuEvent } from './events/ContextMenuEvent'; import { DataEvent } from './events/DataEvent'; import { ErrorEvent } from './events/ErrorEvent'; -import { EventDispatcher } from './events/EventDispatcher'; import { Event } from './events/Event'; +import { EventDispatcher } from './events/EventDispatcher'; import { EventPhase } from './events/EventPhase'; import { FocusEvent } from './events/FocusEvent'; import { FullScreenEvent } from './events/FullScreenEvent'; @@ -104,39 +124,39 @@ import { NumberFormatter } from './globalization/NumberFormatter'; import { Sound } from './media/Sound'; import { SoundChannel } from './media/SoundChannel'; -import { SoundTransform } from './media/SoundTransform'; import { SoundMixer } from './media/SoundMixer'; +import { SoundTransform } from './media/SoundTransform'; import { FileFilter } from './net/FileFilter'; import { FileReference } from './net/FileReference'; +import { LocalConnection } from './net/LocalConnection'; import { SharedObject } from './net/SharedObject'; -import { URLRequest } from './net/URLRequest'; import { URLLoader } from './net/URLLoader'; +import { URLRequest } from './net/URLRequest'; import { URLVariables } from './net/URLVariables'; -import { LocalConnection } from './net/LocalConnection'; -import { SecurityDomain } from './system/SecurityDomain'; +import { ApplicationDomain } from './system/ApplicationDomain'; import { Capabilities } from './system/Capabilities'; import { fscommand } from './system/FSCommand'; -import { Security } from './system/Security'; import { LoaderContext } from './system/LoaderContext'; -import { ApplicationDomain } from './system/ApplicationDomain'; +import { Security } from './system/Security'; +import { SecurityDomain } from './system/SecurityDomain'; import { System } from './system/System'; +import { CSMSettings } from './text/CSMSettings'; import { Font } from './text/Font'; +import { FontType } from './text/FontType'; +import { StaticText } from './text/StaticText'; import { StyleSheet } from './text/StyleSheet'; +import { TextColorType } from './text/TextColorType'; +import { TextDisplayMode } from './text/TextDisplayMode'; +import { TextExtent } from './text/TextExtent'; import { TextField } from './text/TextField'; import { TextFormat } from './text/TextFormat'; -import { TextRun } from './text/TextRun'; -import { StaticText } from './text/StaticText'; -import { TextRenderer } from './text/TextRenderer'; import { TextFormatDisplay } from './text/TextFormatDisplay'; -import { TextExtent } from './text/TextExtent'; -import { TextDisplayMode } from './text/TextDisplayMode'; -import { TextColorType } from './text/TextColorType'; -import { FontType } from './text/FontType'; -import { CSMSettings } from './text/CSMSettings'; import { TextLineMetrics } from './text/TextLineMetrics'; +import { TextRenderer } from './text/TextRenderer'; +import { TextRun } from './text/TextRun'; import { TextSnapshot } from './text/TextSnapshot'; import { CompositionAttributeRange } from './text/ime/CompositionAttributeRange'; @@ -174,27 +194,26 @@ import { TextLineValidity } from './text/engine/TextLineValidity'; import { TextRotation } from './text/engine/TextRotation'; import { TypographicCase } from './text/engine/TypographicCase'; -import { Keyboard } from './ui/Keyboard'; +import { ASClass, ByteArray, registerNativeClass, registerNativeFunction, XMLDocument, XMLNode } from '@awayfl/avm2'; +import { release } from '@awayfl/swf-loader'; +import { BlendMode } from '@awayjs/stage'; +import { GroupElement } from './text/engine/GroupElement'; import { ContextMenu } from './ui/ContextMenu'; -import { ContextMenuItem } from './ui/ContextMenuItem'; import { ContextMenuBuiltInItems } from './ui/ContextMenuBuiltInItems'; import { ContextMenuClipboardItems } from './ui/ContextMenuClipboardItems'; +import { ContextMenuItem } from './ui/ContextMenuItem'; import { GameInput } from './ui/GameInput'; import { GameInputControl } from './ui/GameInputControl'; import { GameInputControlType } from './ui/GameInputControlType'; import { GameInputDevice } from './ui/GameInputDevice'; import { GameInputFinger } from './ui/GameInputFinger'; import { GameInputHand } from './ui/GameInputHand'; +import { Keyboard } from './ui/Keyboard'; import { Mouse } from './ui/Mouse'; -import { MultitouchInputMode } from './ui/MultitouchInputMode'; import { Multitouch } from './ui/Multitouch'; -import { Timer } from './utils/Timer'; +import { MultitouchInputMode } from './ui/MultitouchInputMode'; import { CompressionAlgorithm } from './utils/CompressionAlgorithm'; -import { XMLDocument, XMLNode, ASClass, registerNativeClass, registerNativeFunction } from '@awayfl/avm2'; -import { release } from '@awayfl/swf-loader'; -import { BlendMode } from '@awayjs/stage'; -import { GroupElement } from './text/engine/GroupElement'; -import { ByteArray } from '@awayfl/avm2'; +import { Timer } from './utils/Timer'; import { BaseTextLayoutImporter, Property } from './text/engine/NativehacksForTLF'; @@ -283,7 +302,8 @@ export function initLink() { //M('flash.display.SpreadMethod', SpreadMethod); M('flash.display.Sprite', Sprite); M('flash.display.Stage', Stage); - //M('flash.display.Stage3D', Stage3D); + M('flash.display.Stage3D', Stage3D); + //M('flash.display.StageAlign', StageAlign); //M('flash.display.StageAspectRatio', StageAspectRatio);//AIR //M('flash.display.StageDisplayState', StageDisplayState); @@ -291,8 +311,27 @@ export function initLink() { //M('flash.display.StageScaleMode', StageScaleMode); //M('flash.display.TriangleCulling', TriangleCulling); - // flash.display3D - // flash.display3D.textures + // TODO: Add display3d stuff + + M('flash.display3D.Context3D', Context3D); + M('flash.display3D.Context3DBlendFactor', Context3DBlendFactor); + M('flash.display3D.Context3DClearMask', Context3DClearMask); + M('flash.display3D.Context3DCompareMode', Context3DCompareMode); + M('flash.display3D.Context3DProfile', Context3DProfile); + M('flash.display3D.Context3DProgramType', Context3DProgramType); + M('flash.display3D.Context3DRenderMode', Context3DRenderMode); + M('flash.display3D.Context3DStencilAction', Context3DStencilAction); + M('flash.display3D.Context3DTextureFormat', Context3DTextureFormat); + M('flash.display3D.Context3DTriangleFace', Context3DTriangleFace); + M('flash.display3D.Context3DVertexBufferFormat', Context3DVertexBufferFormat); + M('flash.display3D.IndexBuffer3D', IndexBuffer3D); + M('flash.display3D.Program3D', Program3D); + M('flash.display3D.VertexBuffer3D', VertexBuffer3D); + + M('flash.display3D.textures.TextureBase', TextureBase); + M('flash.display3D.textures.Texture', Texture); + M('flash.display3D.textures.RectangleTexture', Texture); + M('flash.display3D.textures.CubeTexture', CubeTexture); //M('flash.errors.DRMManagerError', DRMManagerError);//AIR M('flash.errors.EOFError', EOFError); diff --git a/lib/media/SoundChannel.ts b/lib/media/SoundChannel.ts index ee0ef68..6a967c7 100644 --- a/lib/media/SoundChannel.ts +++ b/lib/media/SoundChannel.ts @@ -5,7 +5,7 @@ import { SecurityDomain } from '../SecurityDomain'; import { Event } from '../events/Event'; import { EventBase, IAudioChannel } from '@awayjs/core'; import { ISoundSource, SoundMixer } from './SoundMixer'; -import { BaseAudioChannel } from '@awayjs/core/dist/lib/managers/BaseAudioChannel'; +import { BaseAudioChannel } from '@awayjs/core'; /** * Dispatched when a sound has finished playing. diff --git a/lib/net/URLLoader.ts b/lib/net/URLLoader.ts index 069cca9..f7e4436 100644 --- a/lib/net/URLLoader.ts +++ b/lib/net/URLLoader.ts @@ -70,8 +70,7 @@ export class URLLoader extends EventDispatcher { return new ( this.sec).flash.net.URLVariables(rawData); } case URLLoaderDataFormat.BINARY: { - console.warn('[URLLoader] Binary not supported'); - return null; + return new ( this.sec).flash.utils.ByteArray(rawData); } default: { diff --git a/lib/system/Capabilities.ts b/lib/system/Capabilities.ts index 7b251fd..098a21c 100644 --- a/lib/system/Capabilities.ts +++ b/lib/system/Capabilities.ts @@ -54,7 +54,7 @@ export class Capabilities extends ASObject { private static _os: string = null; // static _cpuArchitecture: string; private static _playerType: string = null;// DEFAULT_CAPABILITIES.PLAYER_TYPE; - private static _version: string = 'SHUMWAY 10,0,0,0'; + private static _version: string = 'WIN 32,0,0,465'; // static _screenColor: string; // static _pixelAspectRatio: number; private static _screenDPI: number = 0;// = DEFAULT_CAPABILITIES.SCREEN_DPI;