r3-legacy/src/r3-renderer-d3-0.js

245 lines
6.0 KiB
JavaScript

/**
* R3.Renderer.D3
* @param inherited
* @constructor
*/
R3.Renderer.D3 = function(
inherited
) {
__INHERIT_ONLY__
this.linkedComponents.viewports = [R3.D3.Viewport];
this.linkedComponents.scenes = [R3.D3.Scenes];
R3.Renderer.call(
this,
true
);
};
R3.Renderer.D3.prototype = Object.create(R3.Renderer.prototype);
R3.Renderer.D3.prototype.constructor = R3.Renderer.D3;
/**
* Even though this class cannot be instantiated directly - it can do common tasks for its children
* @returns {*}
*/
R3.Renderer.D3.prototype.createInstance = function() {
if (!this.instance) {
throw new Error('R3.Renderer.D3 createInstance called out of order');
}
this.updateInstance('autoClear');
this.updateInstance('autoClearColor');
this.updateInstance('autoClearDepth');
this.updateInstance('autoClearStencil');
this.updateInstance('gammaFactor');
this.updateInstance('gammaInput');
this.updateInstance('gammaOutput');
this.updateInstance('maxMorphTargets');
this.updateInstance('maxMorphNormals');
this.updateInstance('physicallyCorrectLights');
this.updateInstance('shadowMapEnabled');
this.updateInstance('shadowMapAutoUpdate');
this.updateInstance('shadowMapNeedsUpdate');
this.updateInstance('shadowMapType');
this.updateInstance('sortObjects');
this.updateInstance('toneMapping');
this.updateInstance('toneMappingExposure');
this.updateInstance('toneMappingWhitePoint');
this.updateInstance('localClippingEnabled');
this.updateInstance('clippingPlanes');
this.updateInstance('clearColor');
this.updateInstance('viewports');
this.updateInstance('opacity');
this.updateInstance('pixelRatio');
__CREATE_INSTANCE__;
};
/**
* Update Renderer.D3 Instance
*/
R3.Renderer.D3.prototype.updateInstance = function(property) {
if (!property) {
throw new Error('no renderer property');
}
if (!this.instance) {
throw new Error('no renderer instance');
}
if (property === 'autoClear') {
this.instance.autoClear = this.autoClear;
return;
}
if (property === 'autoClearColor') {
this.instance.autoClearColor = this.autoClearColor;
return;
}
if (property === 'autoClearDepth') {
this.instance.autoClearDepth = this.autoClearDepth;
return;
}
if (property === 'autoClearStencil') {
this.instance.autoClearStencil = this.autoClearStencil;
return;
}
if (property === 'gammaFactor') {
this.instance.gammaFactor = this.gammaFactor;
return;
}
if (property === 'gammaInput') {
this.instance.gammaInput = this.gammaInput;
return;
}
if (property === 'gammaOutput') {
this.instance.gammaOutput = this.gammaOutput;
return;
}
if (property === 'maxMorphTargets') {
this.instance.maxMorphTargets = this.maxMorphTargets;
return;
}
if (property === 'maxMorphNormals') {
this.instance.maxMorphNormals = this.maxMorphNormals;
return;
}
if (property === 'physicallyCorrectLights') {
this.instance.physicallyCorrectLights = this.physicallyCorrectLights;
return;
}
if (property === 'shadowMapEnabled') {
this.instance.shadowMap.enabled = this.shadowMapEnabled;
return;
}
if (property === 'shadowMapAutoUpdate') {
this.instance.shadowMap.autoUpdate = this.shadowMapAutoUpdate;
return;
}
if (property === 'shadowMapNeedsUpdate') {
this.instance.shadowMap.needsUpdate = this.shadowMapNeedsUpdate;
return;
}
if (property === 'shadowMapType') {
this.instance.shadowMap.type = this.shadowMapType;
return;
}
if (property === 'sortObjects') {
this.instance.sortObjects = this.sortObjects;
return;
}
if (property === 'toneMapping') {
this.instance.toneMapping = this.toneMapping;
return;
}
if (property === 'toneMappingExposure') {
this.instance.toneMappingExposure = this.toneMappingExposure;
return;
}
if (property === 'toneMappingWhitePoint') {
this.instance.toneMappingWhitePoint = this.toneMappingWhitePoint;
return;
}
if (property === 'premultipliedAlpha') {
this.instance.premultipliedAlpha = this.premultipliedAlpha;
return;
}
if (property === 'antialias') {
this.instance.antialias = this.antialias;
return;
}
if (property === 'stencil') {
this.instance.stencil = this.stencil;
return;
}
if (property === 'preserveDrawingBuffer') {
this.instance.preserveDrawingBuffer = this.preserveDrawingBuffer;
return;
}
if (property === 'depth') {
this.instance.depth = this.depth;
return;
}
if (property === 'logarithmicDepthBuffer') {
this.instance.logarithmicDepthBuffer = this.logarithmicDepthBuffer;
return;
}
if (property === 'localClippingEnabled') {
this.instance.localClippingEnabled = this.localClippingEnabled;
return;
}
if (property === 'clippingPlanes') {
console.warn('todo: clipping planes change');
return;
}
if (
property === 'clearColor' ||
property === 'opacity'
) {
this.instance.setClearColor(
new THREE.Color(
this.clearColor.r,
this.clearColor.g,
this.clearColor.b
),
this.opacity
);
return;
}
if (property === 'viewports') {
console.warn('todo: viewports change');
}
if (property === 'scenes') {
console.warn('todo: scenes change');
}
if (property === 'alpha') {
this.instance.alpha = this.alpha;
return;
}
if (property === 'pixelRatio') {
this.instance.setPixelRatio(this.pixelRatio);
return;
}
R3.Renderer.prototype.updateInstance.call(this, property);
};
R3.Renderer.D3.prototype.clear = function() {
this.instance.clear();
};