Skip to content

Commit

Permalink
Merge pull request #88 from MasatoMakino/readonly_props
Browse files Browse the repository at this point in the history
Readonly props
  • Loading branch information
MasatoMakino authored Mar 17, 2023
2 parents 3041c64 + a7621ff commit 1381bee
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/CheckBoxObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "./";

export class CheckBoxObject<Value> extends ClickableObject<Value> {
declare view: CheckBoxMesh<Value> | CheckBoxSprite<Value>;
declare readonly view: CheckBoxMesh<Value> | CheckBoxSprite<Value>;
protected _isSelect: boolean = false;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ClickableObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ClickableObject<Value> {
return this._isPress;
}

view: ClickableView<Value>;
readonly view: ClickableView<Value>;
protected _isPress: boolean = false;
protected _isOver: boolean = false;
protected _enable: boolean = true;
Expand Down
2 changes: 1 addition & 1 deletion src/InteractiveMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InteractiveMesh<Value, Model extends ClickableObject<Value>>
extends Mesh
implements IClickableObject3D<Value>
{
public model: Model;
readonly model: Model;

constructor(
parameters: InteractiveMeshParameters,
Expand Down
3 changes: 1 addition & 2 deletions src/InteractiveSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class InteractiveSprite<Value, Model extends ClickableObject<Value>>
extends Sprite
implements IClickableObject3D<Value>
{
public model: Model;

readonly model: Model;
constructor(
material: StateMaterialSet,
ctor: ModelConstructor<Model, Value>
Expand Down
2 changes: 1 addition & 1 deletion src/RadioButtonObject.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CheckBoxObject, RadioButtonMesh, RadioButtonSprite } from "./";

export class RadioButtonObject<Value> extends CheckBoxObject<Value> {
declare view: RadioButtonMesh<Value> | RadioButtonSprite<Value>;
declare readonly view: RadioButtonMesh<Value> | RadioButtonSprite<Value>;
protected _isFrozen: boolean = false;

/**
Expand Down
22 changes: 13 additions & 9 deletions src/ThreeMouseEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ import { ClickableObject, IClickableObject3D } from "./";

export interface ThreeMouseEvent<Value> extends Event {
type: ThreeMouseEventType;
model?: ClickableObject<Value>;
isSelected?: boolean;
readonly model?: ClickableObject<Value>;
readonly isSelected?: boolean;
}

export class ThreeMouseEventUtil {
static generate<Value>(
type: ThreeMouseEventType,
modelOrView: ClickableObject<Value> | IClickableObject3D<Value> | undefined
): ThreeMouseEvent<Value> {
const e: ThreeMouseEvent<Value> = {
type,
model: ThreeMouseEventUtil.getModel(modelOrView),
const model = ThreeMouseEventUtil.getModel(modelOrView);
const getSelection = () => {
if (type === "select") {
return ThreeMouseEventUtil.getSelection(model);
}
return undefined;
};

if (type === "select") {
e.isSelected = ThreeMouseEventUtil.getSelection(e.model);
}
return e;
return {
type,
model,
isSelected: getSelection(),
};
}

private static getModel<Value>(
Expand Down

0 comments on commit 1381bee

Please sign in to comment.