-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStage3D.ts
More file actions
102 lines (87 loc) · 3.04 KB
/
Copy pathStage3D.ts
File metadata and controls
102 lines (87 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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 _adaptee: AwayStage
constructor(i) {
super();
console.log('Stage3D Constructor');
this._adaptee = AVMStage.instance().stage3Ds[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 {
this._context3D = new (this.sec as SecurityDomain).flash.display3D.Context3D(this, context3DRenderMode, profile);
const dispatchContextCreated = (e: Event) => {
this._context3D.removeEventListener(Event.CONTEXT3D_CREATE, dispatchContextCreated);
this.dispatchEvent(new (<SecurityDomain>this.sec).flash.events.Event(Event.CONTEXT3D_CREATE));
}
this._context3D.addEventListener(Event.CONTEXT3D_CREATE, dispatchContextCreated);
setTimeout(() => {
console.log('Request Context');
const forceSoftware: boolean = (context3DRenderMode == 'software');
let awayContextProfile: ContextGLProfile = ContextGLProfile.BASELINE;
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.BASELINE_EXTENDED;
break;
default:
break;
}
console.log('Context3D Config: ', 'forceSoftware: ', forceSoftware, ' profile: ', profile);
this._adaptee.requestContext(forceSoftware, awayContextProfile);
} , 0);
}
}