Skip to content

Commit 320e58c

Browse files
committed
Allow combined camera to impersonate sub types
1 parent a9a0a8c commit 320e58c

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

js/scripts/three-class-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ module.exports = {
161161
height: new Types.Float(),
162162

163163
mode: new Types.Enum("['perspective', 'orthographic']", 'perspective'),
164+
impersonate:new Types.Bool(true),
164165
// view: new Types.ViewOffset()
165166
},
166167
constructorArgs: [ 'width', 'height', 'fov', 'near', 'far', 'orthoNear', 'orthoFar' ],

js/src/cameras/CombinedCamera.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var CombinedCameraModel = CombinedCameraAutogen.extend({
2828
this.convertFloatModelToThree(this.get('orthoNear'), 'orthoNear'),
2929
this.convertFloatModelToThree(this.get('orthoFar'), 'orthoFar')
3030
);
31+
result.impersonate = this.convertBoolModelToThree(
32+
this.get('impersonate'), 'impersonate');
3133
return Promise.resolve(result);
3234

3335
},

js/src/examples/cameras/CombinedCamera.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,37 @@ var CombinedCamera = function ( width, height, fov, near, far, orthoNear, orthoF
3737
this.cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, orthoNear, orthoFar );
3838
this.cameraP = new THREE.PerspectiveCamera( fov, width / height, near, far );
3939

40+
this.impersonate = true;
41+
4042
this.toPerspective();
4143

4244
};
4345

4446
CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
4547
CombinedCamera.prototype.constructor = CombinedCamera;
4648

49+
Object.defineProperties( CombinedCamera.prototype, {
50+
51+
isPerspectiveCamera: {
52+
get: function () {
53+
if (!this.impersonate) {
54+
return undefined;
55+
}
56+
return this.inPerspectiveMode;
57+
}
58+
},
59+
60+
isOrthographicCamera: {
61+
get: function () {
62+
if (!this.impersonate) {
63+
return undefined;
64+
}
65+
return this.inOrthographicMode;
66+
}
67+
}
68+
69+
} );
70+
4771
CombinedCamera.prototype.toPerspective = function () {
4872

4973
// Switches to the Perspective Camera

0 commit comments

Comments
 (0)