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

Support BIMServer 1.5.182 #287 #405

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/plugins/BIMServerLoaderPlugin/BIMServerLoaderPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {utils} from "../../viewer/scene/utils.js";
/**
* {@link Viewer} plugin that loads models from a [BIMServer](http://bimserver.org).
*
* Tested with BIMServer v1.5.120 and IFC schema ifc2x3tc1.
* Tested with BIMServer v1.5.182 and IFC schema ifc2x3tc1.
*
* * For each model loaded, creates a tree of {@link Entity}s within its {@link Viewer}'s {@link Scene}, with the root {@link Entity} representing the model and sub-{@link Entity}s representing objects within the model.
* * The root {@link Entity} will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}.
Expand All @@ -28,7 +28,7 @@ import {utils} from "../../viewer/scene/utils.js";
* we can issue RPC calls to the BIMServer Service Interface. The BIMServerLoaderPlugin makes RPC calls through that
* to download the model and it's IFC metadata.
*
* Note that BIMServerLoaderPlugin works with BIMServer V1.5.120 or later.
* Note that BIMServerLoaderPlugin works with BIMServer V1.5.182 or later.
*
* Read more about this example in the user guide on [Viewing Models from BIMServer](https://github.com/xeokit/xeokit-sdk/wiki/Viewing-Models-from-BIMServer).
*
Expand Down Expand Up @@ -111,7 +111,7 @@ import {utils} from "../../viewer/scene/utils.js";
* });
* });
* ````
* @class BIMServerLoaderPluginOLD
* @class BIMServerLoaderPlugin
*/
class BIMServerLoaderPlugin extends Plugin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function BIMServerPerformanceGeometryLoader(bimServerClient, bimServerClientMode
fieldsToInclude.push("colorsQuantized");

var newQuery = {
doublebuffer: false,
type: "GeometryInfo",
oids: oids,
include: {
Expand Down Expand Up @@ -258,7 +259,7 @@ function BIMServerPerformanceGeometryLoader(bimServerClient, bimServerClientMode
// protocol version assumed to be 16
//---------------------------------------------------------------------------------

const color = new Float32Array([1, 1, 1, 1]);
let color = new Float32Array([1, 1, 1, 1]);

if (geometryType === 1) {

Expand Down Expand Up @@ -568,8 +569,9 @@ function BIMServerPerformanceGeometryLoader(bimServerClient, bimServerClientMode
var indices = stream.readShortArray(nrIndices);
stream.align4();
var b = stream.readIstream;
if (b == 1) {
color = {r: stream.readFloat(), g: stream.readFloat(), b: stream.readFloat(), a: stream.readFloat()};
var rgba;
if (b === 1) {
rgba = {r: stream.readFloat(), g: stream.readFloat(), b: stream.readFloat(), a: stream.readFloat()};
}
stream.align4();
var nrVertices = stream.readInt();
Expand All @@ -587,14 +589,14 @@ function BIMServerPerformanceGeometryLoader(bimServerClient, bimServerClientMode
//primitive: o.type
};

if (color != null) {
if (rgba) {
// Creating vertex colors here anyways (not transmitted over the line is a plus), should find a way to do this with scenejs without vertex-colors
geometry.colors = new Array(nrVertices * 4);
for (var j=0; j<nrVertices; j++) {
geometry.colors[j * 4 + 0] = color.r;
geometry.colors[j * 4 + 1] = color.g;
geometry.colors[j * 4 + 2] = color.b;
geometry.colors[j * 4 + 3] = color.a;
geometry.colors[j * 4 + 0] = rgba.r;
geometry.colors[j * 4 + 1] = rgba.g;
geometry.colors[j * 4 + 2] = rgba.b;
geometry.colors[j * 4 + 3] = rgba.a;
}
}

Expand Down
46 changes: 23 additions & 23 deletions src/plugins/BIMServerLoaderPlugin/lib/DataInputStreamReader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {StringView} from "./StringView.js";
import { StringView } from "./StringView.js";

/**
* @private
Expand All @@ -12,10 +12,10 @@ class DataInputStreamReader {
}

readUTF8() {
var length = this.dataView.getInt16(this.pos);
const length = this.dataView.getInt16(this.pos);
this.pos += 2;
var view = this.arrayBuffer.slice(this.pos, this.pos + length);
var result = new StringView(view).toString();
const view = this.arrayBuffer.slice(this.pos, this.pos + length);
const result = new StringView(view).toString();
this.pos += length;
return result;
}
Expand All @@ -26,87 +26,87 @@ class DataInputStreamReader {

align4() {
// Skips to the next alignment of 4 (source should have done the same!)
var skip = 4 - (this.pos % 4);
if (skip > 0 && skip != 4) {
const skip = 4 - (this.pos % 4);
if (skip > 0 && skip !== 4) {
// console.log("Skip", skip);
this.pos += skip;
}
}

align8() {
// Skips to the next alignment of 4 (source should have done the same!)
var skip = 8 - (this.pos % 8);
if (skip > 0 && skip != 8) {
const skip = 8 - (this.pos % 8);
if (skip > 0 && skip !== 8) {
// console.log("Skip", skip);
this.pos += skip;
}
}

readDoubleArray(length) {
var result = new Float64Array(this.arrayBuffer, this.pos, length);
const result = new Float64Array(this.arrayBuffer, this.pos, length);
this.pos += length * 8;
return result;
}

readFloat() {
var value = this.dataView.getFloat32(this.pos, true);
const value = this.dataView.getFloat32(this.pos, true);
this.pos += 4;
return value;
}

readInt() {
var value = this.dataView.getInt32(this.pos, true);
const value = this.dataView.getInt32(this.pos, true);
this.pos += 4;
return value;
}

readByte() {
var value = this.dataView.getInt8(this.pos);
const value = this.dataView.getInt8(this.pos);
this.pos += 1;
return value;
}

readLong() {
var value = this.dataView.getUint32(this.pos, true) + 0x100000000 * this.dataView.getUint32(this.pos + 4, true);
const value = this.dataView.getUint32(this.pos, true) + 0x100000000 * this.dataView.getUint32(this.pos + 4, true);
this.pos += 8;
return value;
}

readFloatArray2(length) {
var results = [];
for (var i = 0; i < length; i++) {
var value = this.dataView.getFloat32(this.pos, true);
const results = [];
for (let i = 0; i < length; i++) {
const value = this.dataView.getFloat32(this.pos, true);
this.pos += 4;
results.push(value);
}
return results;
}

readFloatArray(length) {
var result = new Float32Array(this.arrayBuffer, this.pos, length);
const result = new Float32Array(this.arrayBuffer, this.pos, length);
this.pos += length * 4;
return result;
}

readIntArray2(length) {
var results = [];
for (var i = 0; i < length; i++) {
var value = this.dataView.getInt32(this.pos, true);
const results = [];
for (let i = 0; i < length; i++) {
const value = this.dataView.getInt32(this.pos, true);
this.pos += 4;
results.push(value);
}
return results;
}

readIntArray(length) {
var result = new Int32Array(this.arrayBuffer, this.pos, length);
const result = new Int32Array(this.arrayBuffer, this.pos, length);
this.pos += length * 4;
return result;
}

readShortArray(length) {
try {
var result = new Int16Array(this.arrayBuffer, this.pos, length);
const result = new Int16Array(this.arrayBuffer, this.pos, length);
this.pos += length * 2;
return result;
} catch (e) {
Expand All @@ -115,4 +115,4 @@ class DataInputStreamReader {
}
}

export {DataInputStreamReader}
export { DataInputStreamReader }
14 changes: 7 additions & 7 deletions src/plugins/BIMServerLoaderPlugin/lib/EventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ EventHandler.prototype.on = function (evt, handler) {
};

EventHandler.prototype.off = function (evt, handler) {
var h = this.handlers[evt];
var found = false;
if (typeof(h) !== 'undefined') {
var i = h.indexOf(handler);
const h = this.handlers[evt];
let found = false;
if (typeof (h) !== 'undefined') {
const i = h.indexOf(handler);
if (i >= -1) {
h.splice(i, 1);
found = true;
Expand All @@ -25,13 +25,13 @@ EventHandler.prototype.off = function (evt, handler) {
};

EventHandler.prototype.fire = function (evt, args) {
var h = this.handlers[evt];
const h = this.handlers[evt];
if (!h) {
return;
}
for (var i = 0; i < h.length; ++i) {
for (let i = 0; i < h.length; ++i) {
h[i].apply(this, args);
}
};

export {EventHandler};
export { EventHandler };
6 changes: 3 additions & 3 deletions src/plugins/BIMServerLoaderPlugin/lib/MetaDataReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function MetaDataRenderer(args) {
}
}
if (typeof(v) !== 'undefined') {
r = s.addRow();
const r = s.addRow();
r.setName(k);
r.setValue(v);
}
Expand Down Expand Up @@ -207,9 +207,9 @@ function MetaDataRenderer(args) {
renderAttributes(o);

o.getIsDefinedBy(function (isDefinedBy) {
if (isDefinedBy.getType() == "IfcRelDefinesByProperties") {
if (isDefinedBy.getType() === "IfcRelDefinesByProperties") {
isDefinedBy.getRelatingPropertyDefinition(function (pset) {
if (pset.getType() == "IfcPropertySet") {
if (pset.getType() === "IfcPropertySet") {
renderPSet(pset);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/BIMServerLoaderPlugin/lib/defaultMaterials.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ const defaultMaterials = {
DEFAULT: [0.5, 0.5, 0.5, 1.0]
};

export {defaultMaterials}
export { defaultMaterials }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function loadBIMServerMetaModel(viewer, modelId, poid, roid, schema, bimServerCl

return new Promise(function (resolve, reject) {

if (schema == "ifc2x3tc1") {
if (schema === "ifc2x3tc1") {
var query = {
defines: {
Representation: {
Expand Down Expand Up @@ -99,7 +99,7 @@ function loadBIMServerMetaModel(viewer, modelId, poid, roid, schema, bimServerCl
}
]
};
} else if (schema == "ifc4") {
} else if (schema === "ifc4") {
var query = {
defines: {
Representation: {
Expand Down Expand Up @@ -294,4 +294,4 @@ function loadBIMServerMetaModel(viewer, modelId, poid, roid, schema, bimServerCl
});
}

export {loadBIMServerMetaModel};
export { loadBIMServerMetaModel };
2 changes: 1 addition & 1 deletion src/plugins/BIMServerLoaderPlugin/lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const Request = {
Make: function make(args) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open(args.method || "GET", args.url, true);
xhr.onload = function (e) {
console.log(args.url, xhr.readyState, xhr.status)
Expand Down