Skip to content

Commit

Permalink
Merge pull request #1200 from xeokit/fix-bcf-lineset-alignement
Browse files Browse the repository at this point in the history
Fix BCF line set rounding error and bitmap Y-flipping
  • Loading branch information
xeolabs authored Oct 26, 2023
2 parents 2eb83f4 + ec1b6a5 commit c12c0ba
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 7 deletions.
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/bookmarking/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@
["saveViewpoint_ortho", "Saving a BCF viewpoint for an orthographic camera"],
["loadViewpoint_ortho", "Loading a BCF viewpoint for an orthographic camera"],
["loadViewpoint_withSectionPlanesPlugin", "Loading a BCF viewpoint with SectionPlanesPlugin"],
["saveViewpoint_BitmapsAndLines", "Saving a BCF viewpoint with bitmaps and lines"]
["saveViewpoint_BitmapsAndLines", "Saving a BCF viewpoint with bitmaps and lines"],
["loadViewpoint_BitmapsAndLines", "Loading a BCF viewpoint with bitmaps and lines"]
],

"Mementos": [
Expand Down
307 changes: 307 additions & 0 deletions examples/bookmarking/loadViewpoint_BitmapsAndLines.html

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/viewer/scene/Bitmap/Bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class Bitmap extends Component {
this._rtcPos = math.vec3();
this._imageSize = math.vec2();

this._texture = new Texture(this);
this._texture = new Texture(this, {
flipY: true
});

this._image = new Image();

if (this._type !== "jpg" && this._type !== "png") {
Expand Down
11 changes: 7 additions & 4 deletions src/viewer/scene/LineSet/LineSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Mesh} from "../mesh/Mesh.js";
import {PhongMaterial} from "../materials/PhongMaterial.js";
import {math} from "../math/math.js";
import {VBOGeometry} from "../geometry/VBOGeometry.js";
import {worldToRTCPositions} from "../math";

/**
* A set of 3D line segments.
Expand Down Expand Up @@ -78,8 +79,10 @@ class LineSet extends Component {
super(owner, cfg);

this._positions = cfg.positions || [];

this._origin = math.vec3(cfg.origin || [0, 0, 0]);
const rtcPositions = new Float32Array(this._positions.length);
const rtcCenter = math.vec3();
const cellSize = 100;
const rtcNeeded = worldToRTCPositions(this._positions, new Float32Array(this._positions.length), rtcCenter, cellSize);

if (cfg.indices) {
this._indices = cfg.indices;
Expand All @@ -97,9 +100,9 @@ class LineSet extends Component {
collidable: cfg.collidable,
geometry: new VBOGeometry(this, {
primitive: "lines",
positions: this._positions,
positions: rtcNeeded ? rtcPositions : this._positions,
indices: this._indices,
origin: cfg.origin
origin: rtcNeeded ? rtcCenter : null
}),
material: new PhongMaterial(this, {
diffuse: cfg.color || [0, 0, 0],
Expand Down
2 changes: 1 addition & 1 deletion src/viewer/scene/model/SceneModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ export class SceneModel extends Component {
cfg.primitive = "triangles";
}
if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
this.error(`[createGeometry] Unsupported value for 'primitive': '${primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
this.error(`[createGeometry] Unsupported value for 'primitive': '${cfg.primitive}' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'.`);
return;
}
if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
Expand Down

0 comments on commit c12c0ba

Please sign in to comment.