Skip to content

Commit

Permalink
spherical harmonics from light estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims committed May 7, 2020
1 parent 9dc4929 commit 2ff789b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/xr/xr-light-estimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Object.assign(pc, function () {
this._rotation = new pc.Quat();
this._color = new pc.Color();

this._sphericalHarmonics = new Float32Array(27);

this._manager.on('start', this._onSessionStart, this);
this._manager.on('end', this._onSessionEnd, this);
};
Expand Down Expand Up @@ -164,6 +166,9 @@ Object.assign(pc, function () {
mat4B.setFromAxisAngle(pc.Vec3.RIGHT, 90); // direcitonal light is looking down
mat4A.mul(mat4B);
this._rotation.setFromMat4(mat4A);

// spherical harmonics
this._sphericalHarmonics.set(lightEstimate.sphericalHarmonicsCoefficients);
};

Object.defineProperty(XrLightEstimation.prototype, 'supported', {
Expand Down Expand Up @@ -205,6 +210,12 @@ Object.assign(pc, function () {
}
});

Object.defineProperty(XrLightEstimation.prototype, 'sphericalHarmonics', {
get: function () {
return this._available ? this._sphericalHarmonics : null;
}
});

return {
XrLightEstimation: XrLightEstimation
};
Expand Down

3 comments on commit 2ff789b

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented on 2ff789b May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious - do we have runtime support for spherical harmonics?

@slimbuck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slimbuck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.