Skip to content

Commit

Permalink
Added unicode example
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Apr 30, 2020
1 parent 78827cc commit a911967
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
19 changes: 19 additions & 0 deletions samples-generator/bin/3d-tiles-samples-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var promises = [
createPointCloudQuantizedOctEncoded(),
createPointCloudBatched(),
createPointCloudWithPerPointProperties(),
createPointCloudWithUnicodePropertyNames(),
createPointCloudWithTransform(),
createPointCloudDraco(),
createPointCloudDracoPartial(),
Expand Down Expand Up @@ -647,6 +648,24 @@ function createPointCloudWithPerPointProperties() {
);
}

function createPointCloudWithUnicodePropertyNames() {
var tileOptions = {
perPointProperties: true,
transform: Matrix4.IDENTITY,
relativeToCenter: false,
unicodePropertyNames: true
};
var tilesetOptions = {
transform: pointCloudTransform,
sphere: pointCloudSphereLocal
};
return savePointCloudTileset(
'PointCloudWithUnicodePropertyNames',
tileOptions,
tilesetOptions
);
}

function createPointCloudWithTransform() {
var tileOptions = {
transform: Matrix4.IDENTITY,
Expand Down
17 changes: 14 additions & 3 deletions samples-generator/lib/createPointCloudTile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var encoderModule = draco3d.createEncoderModule({});
* @param {Boolean} [options.batched=false] Group points together with batch ids and generate per-batch metadata. Good for differentiating different sections of a point cloud. Not compatible with perPointProperties.
* @param {Boolean} [options.perPointProperties=false] Generate per-point metadata.
* @param {Boolean} [options.relativeToCenter=true] Define point positions relative-to-center.
* @param {Boolean} [options.unicodePropertyNames=false] Use unicode characters in per-point property names.
* @param {Boolean} [options.time=0.0] Time value when generating 4D simplex noise.
*
* @returns {Object} An object containing the pnts buffer and batch table JSON.
Expand All @@ -74,6 +75,10 @@ export function createPointCloudTile(options) {
var batched = defaultValue(options.batched, false);
var perPointProperties = defaultValue(options.perPointProperties, false);
var relativeToCenter = defaultValue(options.relativeToCenter, true);
var unicodePropertyNames = defaultValue(
options.unicodePropertyNames,
false
);
var time = defaultValue(options.time, 0.0);

if (colorMode === 'rgb565' && draco) {
Expand Down Expand Up @@ -147,7 +152,8 @@ export function createPointCloudTile(options) {
batchTableProperties = getPerPointBatchTableProperties(
pointsLength,
noiseValues,
use3dTilesNext
use3dTilesNext,
unicodePropertyNames
);
}

Expand Down Expand Up @@ -1083,7 +1089,8 @@ function getBatchTableForBatchedPoints(batchLength, use3dTilesNext) {
function getPerPointBatchTableProperties(
pointsLength,
noiseValues,
use3dTilesNext
use3dTilesNext,
unicodePropertyNames
) {
// Create some sample per-point properties. Each point will have a temperature, secondary color, and id.
var temperaturesBuffer = Buffer.alloc(pointsLength * sizeOfFloat32);
Expand Down Expand Up @@ -1144,10 +1151,14 @@ function getPerPointBatchTableProperties(
);
}

var temperatureName = unicodePropertyNames
? 'temperature ℃'
: 'temperature';

var result: any = [
{
buffer: temperaturesBuffer,
propertyName: 'temperature',
propertyName: temperatureName,
componentType: 'FLOAT',
type: 'SCALAR'
},
Expand Down

0 comments on commit a911967

Please sign in to comment.