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

Feat: Vector4 classes improvement #865

Merged
merged 34 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cf1c1e1
fix this.__htmlImageElement! is undefined error
ishiiyuki Sep 26, 2021
c38c142
fix: the htmlCanvasElement method AbstractTexture.ts
Sep 27, 2021
3aacbdb
fix: add the png file extension for glTF2Exporter
Sep 27, 2021
c46f9e4
feat: add exportGltf2 button and funciton to some samples
Sep 27, 2021
f2a5626
Merge pull request #872 from actnwit/fix/glTFExporter-undefined-error
Sep 27, 2021
a80e661
chore: add a comment for byteStride of Accessor
Sep 27, 2021
36b1249
Merge pull request #873 from actnwit/chore/comment
Sep 28, 2021
1c72d43
feat: add the '_updateCount' getter to MutableVector4
Sep 25, 2021
a6c0dbe
feat: add ConstVector4_1_1_1_1, ConstVector4_0_0_0_1 and ConstVector4…
Sep 25, 2021
c0ad521
feat: add the isArrayBufferOfTheSourceSame method to AbstractVector.ts
Sep 25, 2021
5e158f3
fix: fix the != to !==
Sep 25, 2021
8f71b23
refactor: fix the type of vector classes to interface
Sep 25, 2021
d27eeef
chore: prettifer codes
Sep 25, 2021
66366a4
feat: add the 'isTheSourceSame method to Vector and Matrix classes
Sep 25, 2021
d9d7ccf
chore: remove the test error e2e image
Sep 25, 2021
07e9ff0
feat: fromArrayBuffer, fromArray, _fromVector4, _fromVector3, _fromVe…
Sep 26, 2021
2651904
fix: wrong import statment
Sep 26, 2021
a9c4f52
refactor: remove IVector interface implements
Sep 26, 2021
ed5e4a2
feat: add raw_extension.ts
Sep 26, 2021
e71bef2
feat: add extension methods to Float32Array
Sep 26, 2021
f0f71ca
refactor: refactor the raw_extension.ts
Sep 26, 2021
7190875
add test for raw_extension.ts
Sep 26, 2021
fcf5dfd
feat: add "add4" and "add4_offset" function to ArrayType
Sep 26, 2021
b59a17b
feat: add type Array4<T> and Array3<T> to CommonTypes.ts
Sep 26, 2021
bdc1039
refactor: divide Vector4's constructor process to some static creator…
Sep 26, 2021
6b74d05
refactor: MutableVector4 (WIP)
Sep 26, 2021
7dfff74
refactor: change the signatures of ColorRgba and MutableColorRgba
Sep 26, 2021
386fe47
refactor: add type FloatTypedArray and FloatTypedArrayConstructor
Sep 26, 2021
c255d3c
refactor: change new Vector4() -> Vector4.fromCopyArray
Sep 26, 2021
dacb929
refactor: other changes
Sep 26, 2021
81a1687
fix: clone() method does not work properly
Sep 26, 2021
e9c2218
feat: add fromCopyFloat32Array to Vector4
Sep 26, 2021
5ca526b
refactor: refactor Vector4
Sep 26, 2021
1ddd38f
feat: fromCopyArray4
Sep 26, 2021
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
4 changes: 2 additions & 2 deletions samples/simple/Gltf2ImporterShadow/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ declare const Rn: typeof _Rn;
);
material.setParameter(
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.0, 0.0, 0.0, 0.0)
Rn.Vector4.fromCopyArray([0.0, 0.0, 0.0, 0.0])
);
material.setParameter(
Rn.ShadowMapDecodeClassicSingleMaterialNode.ShadowColorFactor,
new Rn.Vector4(0.0, 0.0, 0.0, 0.5)
Rn.Vector4.fromCopyArray([0.0, 0.0, 0.0, 0.5])
);
material.alphaMode = Rn.AlphaMode.Translucent;

Expand Down
10 changes: 8 additions & 2 deletions samples/simple/NodeEditor/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ declare const Rn: typeof _Rn;
Rn.CompositionType.Vec4,
Rn.ComponentType.Float
);
constant1.setDefaultInputValue('value', new Rn.Vector4(1, 2, 3, 4));
constant1.setDefaultInputValue(
'value',
Rn.Vector4.fromCopyArray([1, 2, 3, 4])
);
const constant2 = new Rn.ConstantVariableShaderNode(
Rn.CompositionType.Vec4,
Rn.ComponentType.Float
);
constant2.setDefaultInputValue('value', new Rn.Vector4(4, 3, 2, 1));
constant2.setDefaultInputValue(
'value',
Rn.Vector4.fromCopyArray([4, 3, 2, 1])
);

const addShaderNode = new Rn.AddShaderNode(
Rn.CompositionType.Vec4,
Expand Down
6 changes: 3 additions & 3 deletions samples/simple/ShadowMapping/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ declare const Rn: typeof _Rn;

const resolutionDepthCamera = 512;

const diffuseColorFactorSmallBoard = new Rn.Vector4(0.5, 0.1, 0.4, 1);
const diffuseColorFactorLargeBoard = new Rn.Vector4(0.1, 0.7, 0.5, 1);
const diffuseColorFactorSmallBoard = Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1]);
const diffuseColorFactorLargeBoard = Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1]);

const shadowColorFactorLargeBoard = new Rn.Vector4(0.05, 0.35, 0.25, 1);
const shadowColorFactorLargeBoard = Rn.Vector4.fromCopyArray([0.05, 0.35, 0.25, 1]);

// ---main algorithm-----------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion samples/simple/SkinShader/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const setupRenderPassEntityUidOutput = function (rootGroup: Entity, cameraCompon

const framebuffer = Rn.RenderableHelper.createTexturesForRenderTarget(canvas.clientWidth, canvas.clientHeight, 1, {});
renderPass.setFramebuffer(framebuffer);
renderPass.clearColor = new Rn.Vector4(0, 0, 0, 1);
renderPass.clearColor = Rn.Vector4.fromCopyArray([0, 0, 0, 1]);
renderPass.toClearColorBuffer = true;
renderPass.toClearDepthBuffer = true;

Expand Down
1 change: 1 addition & 0 deletions samples/simple/VideoTexture/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ <h2>Rendering Test Image</h2>
<canvas id="world" width="600" height="600"></canvas>
<div>
<button onclick="window.isAnimating = true;">Animate</button>
<button onclick="exportGltf2();">Export as glTF2</button>
</div>
</section>
<section class="correct">
Expand Down
5 changes: 5 additions & 0 deletions samples/simple/VideoTexture/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ declare const Rn: typeof _Rn;

draw();
})();

window.exportGltf2 = function () {
const exporter = Rn.Gltf2Exporter.getInstance();
exporter.export('Rhodonite');
};
4 changes: 2 additions & 2 deletions samples/test_e2e/ColorGradingUsingLUTs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ declare const Rn: typeof _Rn;
renderPass.cameraComponent = cameraComponent;

const entitySmallBoard = createEntityColoredBoard(
new Rn.Vector4(0.5, 0.1, 0.4, 1)
Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1])
);
const transformSmallBoard = entitySmallBoard.getTransform();
transformSmallBoard.scale = new Rn.Vector3(0.2, 0.2, 0.2);
transformSmallBoard.translate = new Rn.Vector3(0.0, 0.0, -1.0);
transformSmallBoard.rotate = new Rn.Vector3(Math.PI / 2, 0, 0);

const entityLargeBoard = createEntityColoredBoard(
new Rn.Vector4(0.1, 0.7, 0.5, 1)
Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1])
);
const transformLargeBoard = entityLargeBoard.getTransform();
transformLargeBoard.translate = new Rn.Vector3(15, 30, -1.5);
Expand Down
4 changes: 2 additions & 2 deletions samples/test_e2e/GaussianBlur/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ declare const Rn: typeof _Rn;
renderPass.cameraComponent = cameraComponent;

const entitySmallBoard = createEntityColoredBoard(
new Rn.Vector4(0.5, 0.1, 0.4, 1)
Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1])
);
const transformSmallBoard = entitySmallBoard.getTransform();
transformSmallBoard.scale = new Rn.Vector3(0.2, 0.2, 0.2);
transformSmallBoard.translate = new Rn.Vector3(0.0, 0.0, -1.0);
transformSmallBoard.rotate = new Rn.Vector3(Math.PI / 2, 0, 0);

const entityLargeBoard = createEntityColoredBoard(
new Rn.Vector4(0.1, 0.7, 0.5, 1)
Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1])
);
const transformLargeBoard = entityLargeBoard.getTransform();
transformLargeBoard.translate = new Rn.Vector3(15, 30, -1.5);
Expand Down
6 changes: 3 additions & 3 deletions samples/test_e2e/Gltf2Importer-GlareEffect/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare const Rn: typeof _Rn;
createAndSetFramebuffer(renderPassHDR, rnCanvasElement.width, 1, {
type: Rn.ComponentType.HalfFloat,
});
renderPassHDR.clearColor = new Rn.Vector4(0.0, 0.0, 0.0, 1.0);
renderPassHDR.clearColor = Rn.Vector4.fromCopyArray([0.0, 0.0, 0.0, 1.0]);

const materialHighLuminance = Rn.MaterialHelper.createDetectHighLuminanceMaterial(
{maxInstancesNumber: 1},
Expand Down Expand Up @@ -335,7 +335,7 @@ declare const Rn: typeof _Rn;

// need to draw the full viewport size
renderPassBlurH.setViewport(
new Rn.Vector4(0, 0, resolutionBlur, resolutionBlur)
Rn.Vector4.fromCopyArray([0, 0, resolutionBlur, resolutionBlur])
);
}
renderPassBlurH.cameraComponent = cameraComponentPostEffect;
Expand Down Expand Up @@ -480,7 +480,7 @@ declare const Rn: typeof _Rn;
) {
const renderPass = new Rn.RenderPass();
renderPass.toClearColorBuffer = true;
renderPass.clearColor = new Rn.Vector4(1.0, 1.0, 1.0, 1.0);
renderPass.clearColor = Rn.Vector4.fromCopyArray([1.0, 1.0, 1.0, 1.0]);
renderPass.cameraComponent = cameraComponent;
renderPass.addEntities([entityGlareTarget]);
renderPass.setMaterial(material);
Expand Down
1 change: 1 addition & 0 deletions samples/test_e2e/GltfImporter-draco-extension/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h2>Rendering Test Image</h2>
<canvas id="world" width="600" height="600"></canvas>
<div>
<button onclick="window.isAnimating = true;">Animate</button>
<button onclick="exportGltf2();">Export as glTF2</button>
</div>
</section>
<section class="correct">
Expand Down
6 changes: 6 additions & 0 deletions samples/test_e2e/GltfImporter-draco-extension/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _Rn, {CameraComponent, Material} from '../../../dist/esm/index';

declare const window: any;
declare const Rn: typeof _Rn;
const p = document.createElement('p');
document.body.appendChild(p);
Expand Down Expand Up @@ -183,3 +184,8 @@ function setTextureParameterForMeshComponents(
}
}
}

window.exportGltf2 = function () {
const exporter = Rn.Gltf2Exporter.getInstance();
exporter.export('Rhodonite');
};
4 changes: 4 additions & 0 deletions samples/test_e2e/GltfImporter-ibl-1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ <h1 class="header-title">Rhodonite E2E Test - GltfImporter-ibl-1</h1>
<section class="test">
<h2>Rendering Test Image</h2>
<canvas id="world" width="600" height="600"></canvas>
<div>
<button onclick="window.isAnimating = true;">Animate</button>
<button onclick="exportGltf2();">Export as glTF2</button>
</div>
</section>
<section class="correct">
<h2>Correct PNG Image</h2>
Expand Down
6 changes: 6 additions & 0 deletions samples/test_e2e/GltfImporter-ibl-1/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _Rn, {
} from '../../../dist/esm/index';

declare const Rn: typeof _Rn;
declare const window: any;
const p = document.createElement('p');
document.body.appendChild(p);

Expand Down Expand Up @@ -206,3 +207,8 @@ function setTextureParameterForMeshComponents(
}
}
}

window.exportGltf2 = function () {
const exporter = Rn.Gltf2Exporter.getInstance();
exporter.export('Rhodonite');
};
2 changes: 1 addition & 1 deletion samples/test_e2e/GltfImporter-orbit-moving/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ document.body.appendChild(p);
}
mainExpression.renderPasses[0].toClearColorBuffer = true;
mainExpression.renderPasses[0].toClearDepthBuffer = true;
mainExpression.renderPasses[0].clearColor = new Rn.Vector4(0, 0, 0, 0);
mainExpression.renderPasses[0].clearColor = Rn.Vector4.fromCopyArray([0, 0, 0, 0]);

const postEffectCameraEntity = createPostEffectCameraEntity();
const postEffectCameraComponent = postEffectCameraEntity.getCamera();
Expand Down
2 changes: 1 addition & 1 deletion samples/test_e2e/GltfImporter-specify-noLight/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let p = null;
setParameterForMeshComponents(
meshComponents,
Rn.ShaderSemantics.BaseColorFactor,
new Rn.Vector4(0.5, 0.5, 0.5, 1.0)
Rn.Vector4.fromCopyArray([0.5, 0.5, 0.5, 1.0])
);

// cameraController
Expand Down
8 changes: 4 additions & 4 deletions samples/test_e2e/MultiPass/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ declare const Stats: any;
Promise.all(promises).then(() => {
const system = Rn.System.getInstance();
const entityRepository = Rn.EntityRepository.getInstance();

const gl = system.setProcessApproachAndCanvas(
Rn.ProcessApproach.UniformWebGL1,
document.getElementById('world') as HTMLCanvasElement
Expand Down Expand Up @@ -107,7 +107,7 @@ declare const Stats: any;
//primitive.material.setTextureParameter(Rn.ShaderSemantics.DiffuseColorTexture, texture);
primitive.material.setParameter(
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(1, 0, 1, 1)
Rn.Vector4.fromCopyArray([1, 0, 1, 1])
);

const entities = [];
Expand Down Expand Up @@ -242,7 +242,7 @@ declare const Stats: any;
})();

window.exportGltf2 = function () {

const exporter = Rn.Gltf2Exporter.getInstance();
exporter.export('Rhodonite');
};
};
6 changes: 3 additions & 3 deletions samples/test_e2e/PixelPickingTest/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const setupRenderPassEntityUidOutput = function (
{}
);
renderPass.setFramebuffer(framebuffer);
renderPass.clearColor = new Rn.Vector4(0, 0, 0, 1);
renderPass.clearColor = Rn.Vector4.fromCopyArray([0, 0, 0, 1]);
renderPass.toClearColorBuffer = true;
renderPass.toClearDepthBuffer = true;

Expand Down Expand Up @@ -58,7 +58,7 @@ const pick = function (e: any) {
const pickedPixel = renderTargetTexture.getPixelValueAt(x, y);
console.log(pickedPixel.toString());

const bitDec = new Rn.Vector4(1, 255, 65025, 0);
const bitDec = Rn.Vector4.fromCopyArray([1, 255, 65025, 0]);
const pickedEntityUID = bitDec.dot(pickedPixel);
console.log(pickedEntityUID);

Expand Down Expand Up @@ -209,7 +209,7 @@ let p: any;
})();

window.exportGltf2 = function () {

const exporter = Rn.Gltf2Exporter.getInstance();
exporter.export('Rhodonite');
};
6 changes: 3 additions & 3 deletions samples/test_e2e/ShadowMap/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ document.body.appendChild(p);
setParameterForMeshComponent(
meshComponentSmallBoard,
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.5, 0.1, 0.4, 1)
Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1])
);
setParameterForMeshComponent(
meshComponentLargeBoard,
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.1, 0.7, 0.5, 1)
Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1])
);
setParameterForMeshComponent(
meshComponentLargeBoard,
Rn.ShadowMapDecodeClassicSingleMaterialNode.ShadowColorFactor,
new Rn.Vector4(0.05, 0.35, 0.25, 1)
Rn.Vector4.fromCopyArray([0.05, 0.35, 0.25, 1])
);

const scaleSmallBoard = new Rn.Vector3(0.2, 0.2, 0.2);
Expand Down
8 changes: 4 additions & 4 deletions samples/test_e2e/ShadowMapDebugMode/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ let p: any;
setParameterForMeshComponent(
meshComponentSmallBoard,
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.5, 0.1, 0.4, 1)
Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1])
);
setParameterForMeshComponent(
meshComponentLargeBoard,
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.1, 0.7, 0.5, 1)
Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1])
);
setParameterForMeshComponent(
meshComponentLargeBoard,
Rn.ShadowMapDecodeClassicSingleMaterialNode.DebugColorFactor,
new Rn.Vector4(0.85, 0.0, 0.0, 1.0)
Rn.Vector4.fromCopyArray([0.85, 0.0, 0.0, 1.0])
);
setParameterForMeshComponent(
meshComponentLargeBoard,
Rn.ShadowMapDecodeClassicSingleMaterialNode.ShadowColorFactor,
new Rn.Vector4(0.05, 0.35, 0.25, 1)
Rn.Vector4.fromCopyArray([0.05, 0.35, 0.25, 1])
);

const scaleSmallBoard = new Rn.Vector3(0.2, 0.2, 0.2);
Expand Down
8 changes: 4 additions & 4 deletions samples/test_e2e/ShadowMapVariance/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ declare const Rn: typeof _Rn;
);
materialSphere.setParameter(
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.5, 0.1, 0.4, 1)
Rn.Vector4.fromCopyArray([0.5, 0.1, 0.4, 1])
);
materialSphere.setParameter(
Rn.VarianceShadowMapDecodeClassicSingleMaterialNode.ShadowColor,
new Rn.Vector4(0.25, 0.05, 0.2, 1)
Rn.Vector4.fromCopyArray([0.25, 0.05, 0.2, 1])
);
materialSphere.setParameter(
Rn.VarianceShadowMapDecodeClassicSingleMaterialNode.MinimumVariance,
Expand All @@ -223,11 +223,11 @@ declare const Rn: typeof _Rn;
);
materialBoard.setParameter(
Rn.ShaderSemantics.DiffuseColorFactor,
new Rn.Vector4(0.1, 0.7, 0.5, 1)
Rn.Vector4.fromCopyArray([0.1, 0.7, 0.5, 1])
);
materialBoard.setParameter(
Rn.VarianceShadowMapDecodeClassicSingleMaterialNode.ShadowColor,
new Rn.Vector4(0.05, 0.35, 0.25, 1)
Rn.Vector4.fromCopyArray([0.05, 0.35, 0.25, 1])
);
materialBoard.setParameter(
Rn.VarianceShadowMapDecodeClassicSingleMaterialNode.MinimumVariance,
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/effekseer/EffekseerComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import EntityRepository from '../foundation/core/EntityRepository';
import SceneGraphComponent from '../foundation/components/SceneGraphComponent';
import {ProcessStage} from '../foundation/definitions/ProcessStage';
import TransformComponent from '../foundation/components/TransformComponent';
import Vector3 from '../foundation/math/Vector3';
import CameraComponent from '../foundation/components/CameraComponent';
import ComponentRepository from '../foundation/core/ComponentRepository';
import {WellKnownComponentTIDs} from '../foundation/components/WellKnownComponentTIDs';
Expand All @@ -17,6 +16,7 @@ import {
import Config from '../foundation/core/Config';
import MutableMatrix44 from '../foundation/math/MutableMatrix44';
import {Is} from '../foundation/misc/Is';
import { IVector3 } from '../foundation/math/IVector';

declare let effekseer: any;

Expand Down Expand Up @@ -133,7 +133,7 @@ export default class EffekseerComponent extends Component {
return true;
}

set translate(vec: Vector3) {
set translate(vec: IVector3) {
if (this.__handle) {
this.__handle.setLocation(vec.x, vec.y, vec.z);
}
Expand Down
Loading