claygl-next
Advanced tools
Comparing version 2.0.0-alpha.14 to 2.0.0-alpha.15
@@ -10,7 +10,7 @@ import CompositeNode, { CompositeNodeOutput } from './CompositeNode'; | ||
scene: Scene; | ||
camera: Camera; | ||
camera?: Camera; | ||
autoUpdateScene: boolean; | ||
preZ: boolean; | ||
depthBuffer: boolean; | ||
constructor(scene: Scene, camera: Camera, outputs?: Record<OutputKey, CompositeNodeOutput>); | ||
constructor(scene: Scene, camera?: Camera, outputs?: Record<OutputKey, CompositeNodeOutput>); | ||
prepare(): void; | ||
@@ -17,0 +17,0 @@ render(renderer: Renderer, inputTextures: Record<string, Texture>, outputTextures?: Record<string, Texture>, frameBuffer?: FrameBuffer): void; |
@@ -19,3 +19,3 @@ import CompositeNode from './CompositeNode'; | ||
render(renderer, inputTextures, outputTextures, frameBuffer) { | ||
renderer.render(this.scene, this.camera, frameBuffer, { | ||
renderer.render(this.scene, this.camera || this.scene.getMainCamera(), frameBuffer, { | ||
preZ: this.preZ, | ||
@@ -22,0 +22,0 @@ notUpdateScene: !this.autoUpdateScene |
@@ -1,2 +0,2 @@ | ||
import { COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT, FRAMEBUFFER, RENDERBUFFER } from '../core/constants'; | ||
import { COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT, FRAMEBUFFER, DEPTH_COMPONENT24, RENDERBUFFER } from '../core/constants'; | ||
import { keys } from '../core/util'; | ||
@@ -75,3 +75,3 @@ class GLFrameBuffer { | ||
gl.bindRenderbuffer(RENDERBUFFER, webglRenderBuffer); | ||
gl.renderbufferStorage(RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height); | ||
gl.renderbufferStorage(RENDERBUFFER, DEPTH_COMPONENT24, width, height); | ||
this._webglRbW = width; | ||
@@ -78,0 +78,0 @@ this._webglRbH = height; |
@@ -158,5 +158,2 @@ import * as constants from '../core/constants'; | ||
gl.bindTexture(bindTarget, null); | ||
if (gl.getError()) { | ||
debugger; | ||
} | ||
} | ||
@@ -163,0 +160,0 @@ } |
@@ -49,3 +49,3 @@ import Vector2 from '../math/Vector2'; | ||
*/ | ||
orthographicAspect: number; | ||
aspect: number; | ||
/** | ||
@@ -52,0 +52,0 @@ * Minimum alpha rotation |
@@ -57,3 +57,3 @@ import Vector2 from '../math/Vector2'; | ||
minOrthographicSize: 30, | ||
orthographicAspect: 1, | ||
// aspect: 1, | ||
minAlpha: -90, | ||
@@ -231,3 +231,3 @@ maxAlpha: 90, | ||
'maxOrthographicSize', | ||
'orthographicAspect', | ||
'aspect', | ||
'minAlpha', | ||
@@ -337,2 +337,3 @@ 'maxAlpha', | ||
deltaTime = deltaTime || 16; | ||
const camera = this.target; | ||
if (this._rotating) { | ||
@@ -349,2 +350,16 @@ const radian = (((this.autoRotateDirection === 'cw' ? 1 : -1) * this.autoRotateSpeed) / 180) * Math.PI; | ||
} | ||
// Override the aspect. | ||
const aspect = this.aspect; | ||
if (aspect) { | ||
if (camera instanceof PerspectiveCamera) { | ||
this._needsUpdate || (this._needsUpdate = camera.aspect !== aspect); | ||
camera.aspect = aspect; | ||
} | ||
else if (camera instanceof OrthographicCamera) { | ||
const oldAspect = (camera.right - camera.left) / (camera.top - camera.bottom); | ||
if (Math.abs(aspect - oldAspect) > 1e-4) { | ||
this._needsUpdate = true; | ||
} | ||
} | ||
} | ||
if (!this._needsUpdate) { | ||
@@ -358,4 +373,4 @@ return; | ||
this._updateTransform(); | ||
if (this.target) { | ||
this.target.update(); | ||
if (camera) { | ||
camera.update(); | ||
} | ||
@@ -374,6 +389,8 @@ this.trigger('update'); | ||
_updateDistanceOrSize(deltaTime) { | ||
this._setDistance(this._distance + (this._zoomSpeed * deltaTime) / 20); | ||
if (!(this.target instanceof PerspectiveCamera)) { | ||
this._setOrthoSize(this._orthoSize + (this._zoomSpeed * deltaTime) / 20); | ||
} | ||
else { | ||
this._setDistance(this._distance + (this._zoomSpeed * deltaTime) / 20); | ||
} | ||
this._zoomSpeed *= Math.pow(this.damping, deltaTime / 16); | ||
@@ -389,3 +406,3 @@ } | ||
// TODO | ||
const cameraWidth = cameraHeight * this.orthographicAspect; | ||
const cameraWidth = cameraHeight * (this.aspect || 1); | ||
camera.left = -cameraWidth / 2; | ||
@@ -392,0 +409,0 @@ camera.right = cameraWidth / 2; |
{ | ||
"name": "claygl-next", | ||
"version": "2.0.0-alpha.14", | ||
"version": "2.0.0-alpha.15", | ||
"description": "A 3D graphic library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6990754
105603