Skip to content

Commit ef0178b

Browse files
shadow refresh rate properties included in creation of lights. Added vertical & horizontal flips to occt dimensions + rotation angle for pin label.
1 parent 306b41d commit ef0178b

File tree

5 files changed

+168
-16
lines changed

5 files changed

+168
-16
lines changed

packages/dev/babylonjs/lib/api/bitbybit/babylon/scene.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class BabylonScene {
103103
shadowGenerator.contactHardeningLightSizeUVRatio = inputs.shadowContactHardeningLightSizeUVRatio;
104104
shadowGenerator.bias = inputs.shadowBias;
105105
shadowGenerator.normalBias = inputs.shadowNormalBias;
106+
shadowGenerator.getShadowMap().refreshRate = inputs.shadowRefreshRate;
106107
light.shadowMaxZ = inputs.shadowMaxZ;
107108
light.shadowMinZ = inputs.shadowMinZ;
108109
this.context.scene.metadata.shadowGenerators.push(shadowGenerator);
@@ -169,6 +170,8 @@ export class BabylonScene {
169170
shadowGenerator.contactHardeningLightSizeUVRatio = inputs.shadowContactHardeningLightSizeUVRatio;
170171
shadowGenerator.bias = inputs.shadowBias;
171172
shadowGenerator.normalBias = inputs.shadowNormalBias;
173+
shadowGenerator.getShadowMap().refreshRate = inputs.shadowRefreshRate;
174+
172175
light.shadowMaxZ = inputs.shadowMaxZ;
173176
light.shadowMinZ = inputs.shadowMinZ;
174177
this.context.scene.metadata.shadowGenerators.push(shadowGenerator);

packages/dev/babylonjs/lib/api/bitbybit/draw.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export class Draw extends DrawCore {
240240
},
241241
this.context.scene,
242242
);
243-
243+
ground.isPickable = false;
244244
ground.material = groundMaterial;
245245
return ground;
246246
} catch (e) {

packages/dev/babylonjs/lib/api/inputs/scene-inputs.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export namespace BabylonScene {
4141
vector: Base.Vector3 = [0, -9.81, 0];
4242
}
4343
export class PointLightDto {
44-
constructor(position?: Base.Point3, intensity?: number, diffuse?: Base.Color, specular?: Base.Color, radius?: number, shadowGeneratorMapSize?: number, enableShadows?: boolean, shadowDarkness?: number, shadowUsePercentageCloserFiltering?: boolean, shadowContactHardeningLightSizeUVRatio?: number, shadowBias?: number, shadowNormalBias?: number, shadowMaxZ?: number, shadowMinZ?: number) {
44+
constructor(position?: Base.Point3, intensity?: number, diffuse?: Base.Color, specular?: Base.Color, radius?: number, shadowGeneratorMapSize?: number, enableShadows?: boolean, shadowDarkness?: number, shadowUsePercentageCloserFiltering?: boolean, shadowContactHardeningLightSizeUVRatio?: number, shadowBias?: number, shadowNormalBias?: number, shadowMaxZ?: number, shadowMinZ?: number, shadowRefreshRate?: number) {
4545
if (position !== undefined) { this.position = position; }
4646
if (intensity !== undefined) { this.intensity = intensity; }
4747
if (diffuse !== undefined) { this.diffuse = diffuse; }
@@ -56,6 +56,7 @@ export namespace BabylonScene {
5656
if (shadowNormalBias !== undefined) { this.shadowNormalBias = shadowNormalBias; }
5757
if (shadowMaxZ !== undefined) { this.shadowMaxZ = shadowMaxZ; }
5858
if (shadowMinZ !== undefined) { this.shadowMinZ = shadowMinZ; }
59+
if (shadowRefreshRate !== undefined) { this.shadowRefreshRate = shadowRefreshRate; }
5960
}
6061
/**
6162
* Position of the point light
@@ -155,6 +156,14 @@ export namespace BabylonScene {
155156
* @step 50
156157
*/
157158
shadowMinZ = 0.1;
159+
/**
160+
* Shadow refresh rate
161+
* @default 1
162+
* @minimum 0
163+
* @maximum Infinity
164+
* @step 1
165+
*/
166+
shadowRefreshRate = 1;
158167
}
159168
export class ActiveCameraDto {
160169
constructor(camera?: BABYLON.Camera) {
@@ -176,7 +185,7 @@ export namespace BabylonScene {
176185
use = true;
177186
}
178187
export class DirectionalLightDto {
179-
constructor(direction?: Base.Vector3, intensity?: number, diffuse?: Base.Color, specular?: Base.Color, shadowGeneratorMapSize?: number, enableShadows?: boolean, shadowDarkness?: number, shadowUsePercentageCloserFiltering?: boolean, shadowContactHardeningLightSizeUVRatio?: number, shadowBias?: number, shadowNormalBias?: number, shadowMaxZ?: number, shadowMinZ?: number) {
188+
constructor(direction?: Base.Vector3, intensity?: number, diffuse?: Base.Color, specular?: Base.Color, shadowGeneratorMapSize?: number, enableShadows?: boolean, shadowDarkness?: number, shadowUsePercentageCloserFiltering?: boolean, shadowContactHardeningLightSizeUVRatio?: number, shadowBias?: number, shadowNormalBias?: number, shadowMaxZ?: number, shadowMinZ?: number, shadowRefreshRate?: number) {
180189
if (direction !== undefined) { this.direction = direction; }
181190
if (intensity !== undefined) { this.intensity = intensity; }
182191
if (diffuse !== undefined) { this.diffuse = diffuse; }
@@ -190,6 +199,7 @@ export namespace BabylonScene {
190199
if (shadowNormalBias !== undefined) { this.shadowNormalBias = shadowNormalBias; }
191200
if (shadowMaxZ !== undefined) { this.shadowMaxZ = shadowMaxZ; }
192201
if (shadowMinZ !== undefined) { this.shadowMinZ = shadowMinZ; }
202+
if (shadowRefreshRate !== undefined) { this.shadowRefreshRate = shadowRefreshRate; }
193203
}
194204
/**
195205
* Direction of the directional light
@@ -280,6 +290,14 @@ export namespace BabylonScene {
280290
* @step 50
281291
*/
282292
shadowMinZ = 0;
293+
/**
294+
* Shadow refresh rate
295+
* @default 1
296+
* @minimum 0
297+
* @maximum Infinity
298+
* @step 1
299+
*/
300+
shadowRefreshRate = 1;
283301
}
284302
export class CameraConfigurationDto {
285303
constructor(position?: Base.Point3, lookAt?: Base.Point3, lowerRadiusLimit?: number, upperRadiusLimit?: number, lowerAlphaLimit?: number, upperAlphaLimit?: number, lowerBetaLimit?: number, upperBetaLimit?: number, angularSensibilityX?: number, angularSensibilityY?: number, maxZ?: number, panningSensibility?: number, wheelPrecision?: number) {

packages/dev/occt/lib/api/inputs/occ-inputs.ts

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7041,7 +7041,7 @@ export namespace OCCT {
70417041
direction: Base.Vector3 = [0, 1, 0];
70427042
}
70437043
export class SimpleLinearLengthDimensionDto {
7044-
constructor(start?: Base.Point3, end?: Base.Point3, direction?: Base.Vector3, offsetFromPoints?: number, crossingSize?: number, labelSuffix?: string, labelSize?: number, labelOffset?: number, labelRotation?: number, arrowType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean) {
7044+
constructor(start?: Base.Point3, end?: Base.Point3, direction?: Base.Vector3, offsetFromPoints?: number, crossingSize?: number, labelSuffix?: string, labelSize?: number, labelOffset?: number, labelRotation?: number, arrowType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean, labelFlipHorizontal?: boolean, labelFlipVertical?: boolean) {
70457045
if (start !== undefined) { this.start = start; }
70467046
if (end !== undefined) { this.end = end; }
70477047
if (direction !== undefined) { this.direction = direction; }
@@ -7055,6 +7055,8 @@ export namespace OCCT {
70557055
if (arrowSize !== undefined) { this.arrowSize = arrowSize; }
70567056
if (arrowAngle !== undefined) { this.arrowAngle = arrowAngle; }
70577057
if (arrowsFlipped !== undefined) { this.arrowsFlipped = arrowsFlipped; }
7058+
if (labelFlipHorizontal !== undefined) { this.labelFlipHorizontal = labelFlipHorizontal; }
7059+
if (labelFlipVertical !== undefined) { this.labelFlipVertical = labelFlipVertical; }
70587060
}
70597061
/**
70607062
* The start point for dimension
@@ -7150,9 +7152,19 @@ export namespace OCCT {
71507152
* @default false
71517153
*/
71527154
arrowsFlipped? = false;
7155+
/**
7156+
* Flip label horizontally
7157+
* @default false
7158+
*/
7159+
labelFlipHorizontal? = false;
7160+
/**
7161+
* Flip label vertically
7162+
* @default false
7163+
*/
7164+
labelFlipVertical? = false;
71537165
}
71547166
export class SimpleAngularDimensionDto {
7155-
constructor(direction1?: Base.Point3, direction2?: Base.Point3, center?: Base.Point3, radius?: number, offsetFromCenter?: number, crossingSize?: number, radians?: boolean, labelSuffix?: string, labelSize?: number, labelOffset?: number, endType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean) {
7167+
constructor(direction1?: Base.Point3, direction2?: Base.Point3, center?: Base.Point3, radius?: number, offsetFromCenter?: number, crossingSize?: number, radians?: boolean, labelSuffix?: string, labelSize?: number, labelOffset?: number, endType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean, labelRotation?: number, labelFlipHorizontal?: boolean, labelFlipVertical?: boolean) {
71567168
if (direction1 !== undefined) { this.direction1 = direction1; }
71577169
if (direction2 !== undefined) { this.direction2 = direction2; }
71587170
if (center !== undefined) { this.center = center; }
@@ -7167,6 +7179,9 @@ export namespace OCCT {
71677179
if (arrowSize !== undefined) { this.arrowSize = arrowSize; }
71687180
if (arrowAngle !== undefined) { this.arrowAngle = arrowAngle; }
71697181
if (arrowsFlipped !== undefined) { this.arrowsFlipped = arrowsFlipped; }
7182+
if (labelRotation !== undefined) { this.labelRotation = labelRotation; }
7183+
if (labelFlipHorizontal !== undefined) { this.labelFlipHorizontal = labelFlipHorizontal; }
7184+
if (labelFlipVertical !== undefined) { this.labelFlipVertical = labelFlipVertical; }
71707185
}
71717186

71727187
/**
@@ -7268,9 +7283,27 @@ export namespace OCCT {
72687283
* @default false
72697284
*/
72707285
arrowsFlipped? = false;
7286+
/**
7287+
* Additional rotation angle for the label in degrees
7288+
* @default 0
7289+
* @minimum -360
7290+
* @maximum 360
7291+
* @step 1
7292+
*/
7293+
labelRotation? = 0;
7294+
/**
7295+
* Flip label horizontally
7296+
* @default false
7297+
*/
7298+
labelFlipHorizontal? = false;
7299+
/**
7300+
* Flip label vertically
7301+
* @default false
7302+
*/
7303+
labelFlipVertical? = false;
72717304
}
72727305
export class PinWithLabelDto {
7273-
constructor(startPoint?: Base.Point3, endPoint?: Base.Point3, direction?: Base.Vector3, offsetFromStart?: number, label?: string, labelOffset?: number, labelSize?: number, endType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean) {
7306+
constructor(startPoint?: Base.Point3, endPoint?: Base.Point3, direction?: Base.Vector3, offsetFromStart?: number, label?: string, labelOffset?: number, labelSize?: number, endType?: dimensionEndTypeEnum, arrowSize?: number, arrowAngle?: number, arrowsFlipped?: boolean, labelRotation?: number, labelFlipHorizontal?: boolean, labelFlipVertical?: boolean) {
72747307
if (startPoint !== undefined) { this.startPoint = startPoint; }
72757308
if (endPoint !== undefined) { this.endPoint = endPoint; }
72767309
if (direction !== undefined) { this.direction = direction; }
@@ -7282,6 +7315,9 @@ export namespace OCCT {
72827315
if (arrowSize !== undefined) { this.arrowSize = arrowSize; }
72837316
if (arrowAngle !== undefined) { this.arrowAngle = arrowAngle; }
72847317
if (arrowsFlipped !== undefined) { this.arrowsFlipped = arrowsFlipped; }
7318+
if (labelRotation !== undefined) { this.labelRotation = labelRotation; }
7319+
if (labelFlipHorizontal !== undefined) { this.labelFlipHorizontal = labelFlipHorizontal; }
7320+
if (labelFlipVertical !== undefined) { this.labelFlipVertical = labelFlipVertical; }
72857321
}
72867322
/**
72877323
* The start point for dimension
@@ -7353,6 +7389,24 @@ export namespace OCCT {
73537389
* @default false
73547390
*/
73557391
arrowsFlipped? = false;
7392+
/**
7393+
* Additional rotation angle for the label in degrees
7394+
* @default 0
7395+
* @minimum -360
7396+
* @maximum 360
7397+
* @step 1
7398+
*/
7399+
labelRotation? = 0;
7400+
/**
7401+
* Flip label horizontally
7402+
* @default false
7403+
*/
7404+
labelFlipHorizontal? = false;
7405+
/**
7406+
* Flip label vertically
7407+
* @default false
7408+
*/
7409+
labelFlipVertical? = false;
73567410
}
73577411
export class StarSolidDto extends StarDto {
73587412
constructor(outerRadius?: number, innerRadius?: number, numRays?: number, center?: Base.Point3, direction?: Base.Vector3, offsetOuterEdges?: number, half?: boolean, extrusionLengthFront?: number, extrusionLengthBack?: number) {

packages/dev/occt/lib/services/base/dimensions.service.ts

Lines changed: 87 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,39 @@ export class DimensionsService {
163163
second: inputs.start,
164164
}) as Inputs.Base.Vector3;
165165

166-
const rotated = this.transformsService.rotate({
166+
let currentShape = this.transformsService.rotate({
167167
shape: txt.compound,
168168
angle: -90 + (inputs.labelRotation || 0),
169169
axis: [0, 1, 0],
170170
});
171171

172172
shapesToDelete.push(...txt.shapes.map((s) => s.shape));
173+
let previousShape = currentShape;
174+
175+
// Apply horizontal flip if requested
176+
if (inputs.labelFlipHorizontal) {
177+
currentShape = this.transformsService.scale3d({
178+
shape: currentShape,
179+
scale: [-1, 1, 1],
180+
center: [0, 0, 0]
181+
});
182+
shapesToDelete.push(previousShape);
183+
previousShape = currentShape;
184+
}
185+
186+
// Apply vertical flip if requested
187+
if (inputs.labelFlipVertical) {
188+
currentShape = this.transformsService.scale3d({
189+
shape: currentShape,
190+
scale: [1, 1, -1],
191+
center: [0, 0, 0]
192+
});
193+
shapesToDelete.push(previousShape);
194+
previousShape = currentShape;
195+
}
173196

174197
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
175-
shape: rotated,
198+
shape: currentShape,
176199
fromOrigin: [0, 0, 0],
177200
fromNorm: [0, 1, 0],
178201
fromAx: [0, 0, 1],
@@ -181,7 +204,7 @@ export class DimensionsService {
181204
toAx: dirStartEnd,
182205
});
183206

184-
shapesToDelete.push(rotated);
207+
shapesToDelete.push(previousShape);
185208

186209
const normDir = this.base.vector.normalized({ vector: inputs.direction });
187210
const offsetLabelVec = this.base.vector.mul({ vector: normDir, scalar: inputs.labelOffset });
@@ -315,16 +338,47 @@ export class DimensionsService {
315338
}) as Inputs.Base.Vector3;
316339
const normVecToMid = this.base.vector.normalized({ vector: vectorToMid }) as Inputs.Base.Vector3;
317340

318-
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
341+
let currentShape = this.transformsService.rotate({
319342
shape: txt.compound,
343+
angle: inputs.labelRotation || 0,
344+
axis: [0, 1, 0],
345+
});
346+
347+
shapesToDelete.push(...txt.shapes.map((s) => s.shape));
348+
let previousShape = currentShape;
349+
350+
// Apply horizontal flip if requested
351+
if (inputs.labelFlipHorizontal) {
352+
currentShape = this.transformsService.scale3d({
353+
shape: currentShape,
354+
scale: [-1, 1, 1],
355+
center: [0, 0, 0]
356+
});
357+
shapesToDelete.push(previousShape);
358+
previousShape = currentShape;
359+
}
360+
361+
// Apply vertical flip if requested
362+
if (inputs.labelFlipVertical) {
363+
currentShape = this.transformsService.scale3d({
364+
shape: currentShape,
365+
scale: [1, 1, -1],
366+
center: [0, 0, 0]
367+
});
368+
shapesToDelete.push(previousShape);
369+
previousShape = currentShape;
370+
}
371+
372+
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
373+
shape: currentShape,
320374
fromOrigin: [0, 0, 0],
321375
fromNorm: [0, 1, 0],
322376
fromAx: [0, 0, 1],
323377
toOrigin: [0, 0, 0],
324378
toNorm: normalThreePoints,
325379
toAx: normVecToMid,
326380
});
327-
shapesToDelete.push(...txt.shapes.map((s) => s.shape));
381+
shapesToDelete.push(previousShape);
328382
const offsetLabelVec = this.base.vector.mul({ vector: normVecToMid, scalar: inputs.labelOffset });
329383
const addToDir = this.base.vector.add({
330384
first: midPt,
@@ -439,25 +493,48 @@ export class DimensionsService {
439493
point3: endPtLabelLine,
440494
reverseNormal: false,
441495
});
442-
const rotated = this.transformsService.rotate({
496+
let currentShape = this.transformsService.rotate({
443497
shape: text.compound,
444-
angle: -90,
498+
angle: -90 + (inputs.labelRotation || 0),
445499
axis: [0, 1, 0],
446500
});
447501

448502
const shapesToDelete = text.shapes.map((s) => s.shape);
503+
let previousShape = currentShape;
504+
505+
// Apply horizontal flip if requested
506+
if (inputs.labelFlipHorizontal) {
507+
currentShape = this.transformsService.scale3d({
508+
shape: currentShape,
509+
scale: [-1, 1, 1],
510+
center: [0, 0, 0]
511+
});
512+
shapesToDelete.push(previousShape);
513+
previousShape = currentShape;
514+
}
515+
516+
// Apply vertical flip if requested
517+
if (inputs.labelFlipVertical) {
518+
currentShape = this.transformsService.scale3d({
519+
shape: currentShape,
520+
scale: [1, 1, -1],
521+
center: [0, 0, 0]
522+
});
523+
shapesToDelete.push(previousShape);
524+
previousShape = currentShape;
525+
}
449526

450527
const alignedLabelTxtToDir = this.transformsService.alignNormAndAxis({
451-
shape: rotated,
528+
shape: currentShape,
452529
fromOrigin: [0, 0, 0],
453530
fromNorm: [0, 1, 0],
454531
fromAx: [0, 0, 1],
455532
toOrigin: [0, 0, 0],
456533
toNorm: normalThreePoints,
457534
toAx: dirNorm as Inputs.Base.Vector3,
458535
});
459-
460-
shapesToDelete.push(rotated);
536+
537+
shapesToDelete.push(previousShape);
461538

462539
const addToDir = this.base.vector.add({
463540
first: endPtLabelLine,

0 commit comments

Comments
 (0)