Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Stage3D Implementation #24

Open
wants to merge 43 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e798f84
Initial Stage3D Stuff
Fancy2209 Sep 10, 2024
ae53bb0
Add Stage3D to SecurityDomain
Fancy2209 Sep 10, 2024
675767c
Commit Progress
Fancy2209 Sep 10, 2024
b9e8186
Consitency Fix
Fancy2209 Sep 10, 2024
af7ae3a
Add comment to remind myself
Fancy2209 Sep 10, 2024
e5edc12
Fixed by eslint
Fancy2209 Sep 10, 2024
5d8f5da
Fix requested Context Profile and Minor Fixes
Fancy2209 Sep 10, 2024
6b49026
Comit current work
Fancy2209 Sep 10, 2024
a50c368
Update Stage.ts
Fancy2209 Sep 11, 2024
723bb11
Commit work
Fancy2209 Sep 11, 2024
073ca3c
Commit Work
Fancy2209 Sep 11, 2024
2bd0f96
Commit work
Fancy2209 Sep 11, 2024
d0882ea
Vectors suck
Fancy2209 Sep 11, 2024
10ba69b
it almost works?
Fancy2209 Sep 12, 2024
7423401
Commit work
Fancy2209 Sep 13, 2024
e9ac84d
Fix
Fancy2209 Sep 13, 2024
1d2a3eb
fix
Fancy2209 Sep 13, 2024
f7ba23b
Temp Prog 3D Fix
Fancy2209 Sep 14, 2024
388d0a2
Fix DataPerVertex in VertexBuffer & Fixed by eslint
Fancy2209 Sep 16, 2024
26e0923
Merge branch 'awayfl:dev' into stage3d
Fancy2209 Sep 16, 2024
cb8705b
Add Missing classes from shumway and temp fix for setProgramConstants…
Fancy2209 Sep 16, 2024
d8d1d4c
Merge branch 'stage3d' of https://github.com/fancy2209/playerglobal i…
Fancy2209 Sep 16, 2024
9b47776
forgot to comm some changes
Fancy2209 Sep 16, 2024
10b5828
Add missing Context3D Getters and fix some oversights
Fancy2209 Sep 17, 2024
2fbf9fc
Cleanup
Fancy2209 Sep 17, 2024
ac525b3
check event
Fancy2209 Sep 17, 2024
c9f561d
Listen dor events
Fancy2209 Sep 17, 2024
1b27c86
Minor Fix
Fancy2209 Sep 20, 2024
36d2450
Implement Binary URLLoader
Fancy2209 Sep 23, 2024
4438bda
Fix flash.system.Capabilities.version
Fancy2209 Sep 23, 2024
413a535
Implement Textures
Fancy2209 Sep 23, 2024
67d90da
Ignore Mips for now, ignore setVertexBufferAt if no Program is set, p…
Fancy2209 Sep 23, 2024
81bfd52
Fix based on stage change
Fancy2209 Sep 24, 2024
cd8da2b
Revert Null Fix (Didn't work, just made nothing render)
Fancy2209 Sep 24, 2024
e2d5d5a
Fix null stuff
Fancy2209 Sep 24, 2024
7612f9e
Additional null fix
Fancy2209 Sep 24, 2024
27a99f1
Final fix for Null setVertexAt (for now)
Fancy2209 Sep 24, 2024
f923db7
Make requestContext3D async (doesn't fix all starling issues)
Fancy2209 Sep 30, 2024
869f233
Fix LoaderInfo.UncaughtErrorEvents
Fancy2209 Sep 30, 2024
6c048f0
Fix contentScaleFactor (0 breaks stuff who checks it)
Fancy2209 Sep 30, 2024
8323f4f
Comit work, fix WebPack without dist
Fancy2209 Oct 3, 2024
8d2c2f3
Merge branch 'dev' of https://github.com/awayfl/playerglobal into sta…
Fancy2209 Oct 3, 2024
89f4b90
Merge branch 'dev' of https://github.com/awayfl/playerglobal into sta…
Fancy2209 Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ npm-debug.log

# Misc
deploy_key
deploy_key.pub
deploy_key.pub
.vscode/settings.json
21 changes: 21 additions & 0 deletions lib/SecurityDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {}

Expand All @@ -84,6 +92,7 @@ export class SecurityDomain extends AXSecurityDomain {
DisplayObject: DisplayObject,
DisplayObjectContainer: DisplayObjectContainer,
Stage: Stage,
Stage3D: Stage3D,
Loader: Loader,
LoaderInfo: LoaderInfo,
MovieClip: MovieClip,
Expand All @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion lib/display/LoaderInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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;

}

Expand Down
17 changes: 11 additions & 6 deletions lib/display/Stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down Expand Up @@ -153,7 +155,7 @@ import { InteractiveObject } from './InteractiveObject';

export class Stage extends DisplayObjectContainer {

private _stage3Ds: AwayStage[];
private _stage3Ds: GenericVector;

private _sendEventRender: boolean;

Expand All @@ -162,7 +164,10 @@ export class Stage extends DisplayObjectContainer {

this._isStage = true;

this._stage3Ds = [];
this._stage3Ds = new (<SecurityDomain> this.sec).ObjectVector();
for (let i: number = 0; i < AVMStage.instance().stage3Ds.length; i++) {
this._stage3Ds.axSetNumericProperty(i, new (<SecurityDomain> this.sec).flash.display.Stage3D(i));
}

// resize event listens on window
this._resizeCallbackDelegate = (event: any) => this.resizeCallback(event);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1143,4 +1148,4 @@ export class Stage extends DisplayObjectContainer {
return false;
}

}
}
104 changes: 104 additions & 0 deletions lib/display/Stage3D.ts
Original file line number Diff line number Diff line change
@@ -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 (<SecurityDomain>stage3D.sec).flash.events.Event(Event.CONTEXT3D_CREATE));
}
stage3D._context3D.addEventListener(Event.CONTEXT3D_CREATE, dispatchContextCreated)
stage3D._adaptee.requestContext(forceSoftware, awayContextProfile);},1)
}
}
Loading