создал сцену, привязал механизма управления, добавил дополнительный материал , создал анимации при нажатии

This commit is contained in:
Georgy Shive 2025-01-30 13:10:27 +07:00
commit af67aeb25b
31 changed files with 5154 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://docs.cocos.com/creator/manual/en/scripting/setup.html#custom-script-template

View File

@ -0,0 +1,12 @@
{
"texture": {
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "linear"
},
"erp-texture-cube": {
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "linear"
}
}

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
#///////////////////////////
# Cocos Creator 3D Project
#///////////////////////////
library/
temp/
local/
build/
profiles/
native
#//////////////////////////
# NPM
#//////////////////////////
node_modules/
#//////////////////////////
# VSCode
#//////////////////////////
.vscode/
#//////////////////////////
# WebStorm
#//////////////////////////
.idea/

11
assets/3d_models.meta Normal file
View File

@ -0,0 +1,11 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "8dadf7b6-c199-4c19-9488-ffeb6ef8205f",
"files": [],
"subMetas": {},
"userData": {
"isBundle": true
}
}

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"ver": "1.0.0",
"importer": "*",
"imported": true,
"uuid": "2dbb8e72-c7d3-4408-a894-7f9a7cdab6f9",
"files": [
".blend",
".json"
],
"subMetas": {},
"userData": {}
}

BIN
assets/3d_models/zavod.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

11
assets/Materials.meta Normal file
View File

@ -0,0 +1,11 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "648d7fec-fa6d-4ff7-8e0e-019d161c727a",
"files": [],
"subMetas": {},
"userData": {
"isBundle": true
}
}

View File

@ -0,0 +1,63 @@
{
"__type__": "cc.Material",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"_effectAsset": {
"__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"__expectedType__": "cc.EffectAsset"
},
"_techIdx": 1,
"_defines": [
{
"USE_INSTANCING": true,
"USE_ALPHA_TEST": true
},
{},
{}
],
"_states": [
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
},
{
"rasterizerState": {},
"depthStencilState": {},
"blendState": {
"targets": [
{}
]
}
}
],
"_props": [
{
"mainColor": {
"__type__": "cc.Color",
"r": 255,
"g": 0,
"b": 0,
"a": 255
},
"alphaThreshold": 0
},
{},
{}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.21",
"importer": "material",
"imported": true,
"uuid": "87709558-365a-450a-a64e-6154a5c5ef18",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

9
assets/Scenes.meta Normal file
View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "3de2d529-8c97-4d20-9266-cf5c48d95ed6",
"files": [],
"subMetas": {},
"userData": {}
}

740
assets/Scenes/scene.scene Normal file
View File

@ -0,0 +1,740 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "scene",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_name": "scene",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 5
},
{
"__id__": 10
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 24
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 25
},
"_id": "955c22b7-7b7e-4af8-ad45-8415a0c23e60"
},
{
"__type__": "cc.Node",
"_name": "Main Light",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0.996,
"y": 1.671,
"z": 1.436
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.06397656665577071,
"y": -0.44608233363525845,
"z": -0.8239028751062036,
"w": -0.3436591377065261
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -117.894,
"y": -194.909,
"z": 38.562
},
"_id": "c0y6F5f+pAvI805TdmxIjx"
},
{
"__type__": "cc.DirectionalLight",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 250,
"b": 240,
"a": 255
},
"_useColorTemperature": false,
"_colorTemperature": 6550,
"_staticSettings": {
"__id__": 4
},
"_visibility": -325058561,
"_illuminanceHDR": 65000,
"_illuminance": 65000,
"_illuminanceLDR": 1.6927083333333335,
"_shadowEnabled": true,
"_shadowPcf": 2,
"_shadowBias": 0.00001,
"_shadowNormalBias": 0,
"_shadowSaturation": 1,
"_shadowDistance": 50,
"_shadowInvisibleOcclusionRange": 200,
"_csmLevel": 4,
"_csmLayerLambda": 0.75,
"_csmOptimizationMode": 2,
"_csmAdvancedOptions": false,
"_csmLayersTransition": false,
"_csmTransitionRange": 0.05,
"_shadowFixedArea": false,
"_shadowNear": 0.1,
"_shadowFar": 10,
"_shadowOrthoSize": 5,
"_id": "597uMYCbhEtJQc0ffJlcgA"
},
{
"__type__": "cc.StaticLightSettings",
"_baked": false,
"_editorOnly": false,
"_castShadow": true
},
{
"__type__": "cc.Node",
"_name": "Player",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 6
}
],
"_active": true,
"_components": [
{
"__id__": 9
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "d6FlzGFRpN07QYAnUY0l2i"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 5
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
},
{
"__id__": 8
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 83.5,
"y": 31.7,
"z": 93.6
},
"_lrot": {
"__type__": "cc.Quat",
"x": -0.14640662047956113,
"y": 0.13593483636331533,
"z": 0.020315597412727305,
"w": 0.9796295719527848
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 0.9999999999999999,
"y": 0.9999999999999999,
"z": 0.9999999999999999
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": -17,
"y": 15.8,
"z": 0
},
"_id": "c9DMICJLFO5IeO07EPon7U"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 6
},
"_enabled": true,
"__prefab": null,
"_projection": 1,
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 10,
"_near": 1,
"_far": 1000,
"_color": {
"__type__": "cc.Color",
"r": 20,
"g": 70,
"b": 199,
"a": 228
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 14,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_aperture": 19,
"_shutter": 7,
"_iso": 0,
"_screenScale": 1,
"_visibility": 1822425087,
"_targetTexture": null,
"_postProcess": null,
"_usePostProcess": false,
"_cameraType": -1,
"_trackingType": 0,
"_id": "7dWQTpwS5LrIHnc1zAPUtf"
},
{
"__type__": "96ff6EZCmtHRYuI/W42BPVH",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 6
},
"_enabled": true,
"__prefab": null,
"camera": {
"__id__": 7
},
"_id": "15soFqcgdCMbvX+pFNz+59"
},
{
"__type__": "5d80eQJlnxA9ooItxxIqddm",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"camera": {
"__id__": 6
},
"moveSpeed": 5,
"lookSpeed": 0.1,
"_id": "7cH2FFooBN24GrXsC9B7bn"
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 11
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "e4b19cae-fc01-427a-9539-1caf9ed336dc@9d8cd",
"__expectedType__": "cc.Prefab"
},
"fileId": "e3qj6EstFbTLanhkHAHI3H",
"instance": {
"__id__": 12
},
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "b3fkY3t9xFk719XjR8/42Z",
"prefabRootNode": null,
"mountedChildren": [],
"mountedComponents": [
{
"__id__": 13
}
],
"propertyOverrides": [
{
"__id__": 17
},
{
"__id__": 19
},
{
"__id__": 20
},
{
"__id__": 21
},
{
"__id__": 22
}
],
"removedComponents": []
},
{
"__type__": "cc.MountedComponentsInfo",
"targetInfo": {
"__id__": 14
},
"components": [
{
"__id__": 15
},
{
"__id__": 16
}
]
},
{
"__type__": "cc.TargetInfo",
"localID": [
"7e0P1Qa8BWqZybSQ004ETy"
]
},
{
"__type__": "04b2bx0wWRFNZUDzjOKuS7p",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {
"mountedRoot": {
"__id__": 10
}
},
"node": null,
"_enabled": true,
"__prefab": null,
"redMaterial": {
"__uuid__": "87709558-365a-450a-a64e-6154a5c5ef18",
"__expectedType__": "cc.Material"
},
"_id": "eaSSmiiThFjaEPhMDt3+AW"
},
{
"__type__": "cc.MeshCollider",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {
"mountedRoot": {
"__id__": 10
}
},
"node": null,
"_enabled": true,
"__prefab": null,
"_material": null,
"_isTrigger": false,
"_center": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_mesh": {
"__uuid__": "e4b19cae-fc01-427a-9539-1caf9ed336dc@35e77",
"__expectedType__": "cc.Mesh"
},
"_convex": true,
"_id": "5dDNkgQKhBz7uCAXrFQ0Gr"
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 18
},
"propertyPath": [
"_name"
],
"value": "zavod"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"e3qj6EstFbTLanhkHAHI3H"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 18
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 18
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 18
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 23
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 63.00178146362305,
"y": 11.668142318725586,
"z": -50.533321380615234
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"f1sHrOZdFZ/qBZItaRp/PP"
]
},
{
"__type__": "cc.PrefabInfo",
"root": null,
"asset": null,
"fileId": "5f021970-8878-42ed-9bc2-8c408b7b88f4",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 10
}
]
},
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 26
},
"shadows": {
"__id__": 27
},
"_skybox": {
"__id__": 28
},
"fog": {
"__id__": 29
},
"octree": {
"__id__": 30
},
"skin": {
"__id__": 31
},
"lightProbeInfo": {
"__id__": 32
},
"postSettings": {
"__id__": 33
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false
},
{
"__type__": "cc.AmbientInfo",
"_skyColorHDR": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.5,
"z": 0.8,
"w": 0.520833125
},
"_skyColor": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.5,
"z": 0.8,
"w": 0.520833125
},
"_skyIllumHDR": 20000,
"_skyIllum": 20000,
"_groundAlbedoHDR": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.2,
"z": 0.2,
"w": 1
},
"_groundAlbedo": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.2,
"z": 0.2,
"w": 1
},
"_skyColorLDR": {
"__type__": "cc.Vec4",
"x": 0.452588,
"y": 0.607642,
"z": 0.755699,
"w": 0
},
"_skyIllumLDR": 0.8,
"_groundAlbedoLDR": {
"__type__": "cc.Vec4",
"x": 0.618555,
"y": 0.577848,
"z": 0.544564,
"w": 0
}
},
{
"__type__": "cc.ShadowsInfo",
"_enabled": true,
"_type": 1,
"_normal": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1,
"z": 0
},
"_distance": 0,
"_planeBias": 1,
"_shadowColor": {
"__type__": "cc.Color",
"r": 76,
"g": 76,
"b": 76,
"a": 255
},
"_maxReceived": 4,
"_size": {
"__type__": "cc.Vec2",
"x": 2048,
"y": 2048
}
},
{
"__type__": "cc.SkyboxInfo",
"_envLightingType": 1,
"_envmapHDR": {
"__uuid__": "d032ac98-05e1-4090-88bb-eb640dcb5fc1@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_envmap": {
"__uuid__": "d032ac98-05e1-4090-88bb-eb640dcb5fc1@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_envmapLDR": {
"__uuid__": "6f01cf7f-81bf-4a7e-bd5d-0afc19696480@b47c0",
"__expectedType__": "cc.TextureCube"
},
"_diffuseMapHDR": null,
"_diffuseMapLDR": null,
"_enabled": true,
"_useHDR": true,
"_editableMaterial": null,
"_reflectionHDR": null,
"_reflectionLDR": null,
"_rotationAngle": 0
},
{
"__type__": "cc.FogInfo",
"_type": 0,
"_fogColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_enabled": false,
"_fogDensity": 0.3,
"_fogStart": 0.5,
"_fogEnd": 300,
"_fogAtten": 5,
"_fogTop": 1.5,
"_fogRange": 1.2,
"_accurate": false
},
{
"__type__": "cc.OctreeInfo",
"_enabled": false,
"_minPos": {
"__type__": "cc.Vec3",
"x": -1024,
"y": -1024,
"z": -1024
},
"_maxPos": {
"__type__": "cc.Vec3",
"x": 1024,
"y": 1024,
"z": 1024
},
"_depth": 8
},
{
"__type__": "cc.SkinInfo",
"_enabled": false,
"_blurRadius": 0.01,
"_sssIntensity": 3
},
{
"__type__": "cc.LightProbeInfo",
"_giScale": 1,
"_giSamples": 1024,
"_bounces": 2,
"_reduceRinging": 0,
"_showProbe": true,
"_showWireframe": true,
"_showConvex": false,
"_data": null,
"_lightProbeSphereVolume": 1
},
{
"__type__": "cc.PostSettingsInfo",
"_toneMappingType": 0
}
]

View File

@ -0,0 +1,11 @@
{
"ver": "1.1.50",
"importer": "scene",
"imported": true,
"uuid": "955c22b7-7b7e-4af8-ad45-8415a0c23e60",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

9
assets/Scripts.meta Normal file
View File

@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "c23d010d-a165-4294-a4d2-73db0c91aaae",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,116 @@
import { _decorator, Component, Node, input, Input, EventKeyboard, EventMouse, KeyCode, Vec3, Quat } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('FirstPersonController')
export class FirstPersonController extends Component {
@property({ type: Node })
public camera: Node | null = null;
@property
public moveSpeed: number = 5;
@property
public lookSpeed: number = 0.1;
private _moveDirection: Vec3 = new Vec3();
private _eulerAngles: Vec3 = new Vec3();
private _isLeftMousePressed: boolean = false; // Флаг для отслеживания состояния левой кнопки мыши
onLoad() {
input.on(Input.EventType.KEY_DOWN, this._onKeyDown, this);
input.on(Input.EventType.KEY_UP, this._onKeyUp, this);
input.on(Input.EventType.MOUSE_DOWN, this._onMouseDown, this);
input.on(Input.EventType.MOUSE_UP, this._onMouseUp, this);
input.on(Input.EventType.MOUSE_MOVE, this._onMouseMove, this);
if (this.camera) {
this._eulerAngles = this.camera.eulerAngles.clone();
}
}
onDestroy() {
input.off(Input.EventType.KEY_DOWN, this._onKeyDown, this);
input.off(Input.EventType.KEY_UP, this._onKeyUp, this);
input.off(Input.EventType.MOUSE_DOWN, this._onMouseDown, this);
input.off(Input.EventType.MOUSE_UP, this._onMouseUp, this);
input.off(Input.EventType.MOUSE_MOVE, this._onMouseMove, this);
}
private _onKeyDown(event: EventKeyboard) {
switch (event.keyCode) {
case KeyCode.KEY_W:
this._moveDirection.z = 1;
break;
case KeyCode.KEY_S:
this._moveDirection.z = -1;
break;
case KeyCode.KEY_A:
this._moveDirection.x = -1;
break;
case KeyCode.KEY_D:
this._moveDirection.x = 1;
break;
case KeyCode.KEY_Q:
this._moveDirection.y = -1;
break;
case KeyCode.KEY_E:
this._moveDirection.y = 1;
break;
}
}
private _onKeyUp(event: EventKeyboard) {
switch (event.keyCode) {
case KeyCode.KEY_W:
case KeyCode.KEY_S:
this._moveDirection.z = 0;
break;
case KeyCode.KEY_A:
case KeyCode.KEY_D:
this._moveDirection.x = 0;
break;
case KeyCode.KEY_Q:
case KeyCode.KEY_E:
this._moveDirection.y = 0;
break;
}
}
private _onMouseDown(event: EventMouse) {
if (event.getButton() === 0) { // 0 соответствует левой кнопке мыши
this._isLeftMousePressed = true;
}
}
private _onMouseUp(event: EventMouse) {
if (event.getButton() === 0) { // 0 соответствует левой кнопке мыши
this._isLeftMousePressed = false;
}
}
private _onMouseMove(event: EventMouse) {
if (this.camera && this._isLeftMousePressed) {
this._eulerAngles.y -= event.movementX * this.lookSpeed;
this._eulerAngles.x -= event.movementY * this.lookSpeed;
this._eulerAngles.x = Math.max(-89, Math.min(89, this._eulerAngles.x));
const rotation = Quat.fromEuler(new Quat(), this._eulerAngles.x, this._eulerAngles.y, 0);
this.camera.setRotation(rotation);
}
}
update(deltaTime: number) {
if (this.camera) {
const forward = Vec3.transformQuat(new Vec3(), Vec3.FORWARD, this.camera.worldRotation);
const right = Vec3.transformQuat(new Vec3(), Vec3.RIGHT, this.camera.worldRotation);
const up = Vec3.UP;
const move = new Vec3();
Vec3.scaleAndAdd(move, move, forward, this._moveDirection.z * this.moveSpeed * deltaTime);
Vec3.scaleAndAdd(move, move, right, this._moveDirection.x * this.moveSpeed * deltaTime);
Vec3.scaleAndAdd(move, move, up, this._moveDirection.y * this.moveSpeed * deltaTime);
this.node.translate(move);
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "5d80e409-967c-40f6-8a08-b71c48a9d766",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,82 @@
import { _decorator, Component, Node, CameraComponent, PhysicsSystem, geometry, Vec3, EventMouse, input, Input } from 'cc';
import { PulsatingHighlighter } from './PulsatingHighlighter';
const { ccclass, property } = _decorator;
@ccclass('ModelSelector')
export class ModelSelector extends Component {
@property({ type: CameraComponent })
public camera: CameraComponent | null = null;
private _ray = new geometry.Ray();
private _lastHighlighted: PulsatingHighlighter | null = null;
private _clickCount = 0;
private _doubleClickThreshold = 0.3; // 300 мс между кликами
onLoad() {
input.on(Input.EventType.MOUSE_UP, this._onMouseUp, this);
}
onDestroy() {
input.off(Input.EventType.MOUSE_UP, this._onMouseUp, this);
}
private _onMouseUp(event: EventMouse) {
if (event.getButton() !== 2) return; // Используем правую кнопку мыши
console.log('🖱 Правый клик зафиксирован!');
// Отменяем предыдущий таймер, если он был установлен
this.unschedule(this._resetClickCount);
this._clickCount++;
if (this._clickCount === 2) {
console.log('✅ Двойной клик зафиксирован!');
this._performRaycast(event);
this._clickCount = 0;
} else {
// Устанавливаем сброс кликов через `this.scheduleOnce()`
this.scheduleOnce(this._resetClickCount, this._doubleClickThreshold);
}
}
private _resetClickCount() {
this._clickCount = 0;
console.log('⏳ Сброс двойного клика из-за таймаута.');
}
private _performRaycast(event: EventMouse) {
if (!this.camera) {
console.warn('🚨 Камера не найдена!');
return;
}
// Создаем луч
const screenPos = new Vec3(event.getLocationX(), event.getLocationY(), 0);
this.camera.screenPointToRay(screenPos.x, screenPos.y, this._ray);
console.log('🔍 Запускаем raycast...');
if (PhysicsSystem.instance.raycast(this._ray)) {
const results = PhysicsSystem.instance.raycastResults;
if (results.length > 0) {
const hitNode = results[0].collider.node;
console.log(`🎯 Попадание по объекту: ${hitNode.name}`);
this._highlightModel(hitNode);
} else {
console.log('❌ Raycast ничего не нашел.');
}
} else {
console.log('⚠️ Raycast не сработал.');
}
}
// В классе ModelSelector
private _highlightModel(model: Node) {
const switcher = model.getComponent( PulsatingHighlighter);
if (switcher) {
switcher.switchToRed();
}
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "96ff6119-0a6b-4745-8b88-fd6e3604f547",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -0,0 +1,94 @@
import { _decorator, Component, MeshRenderer, Material, Color, math } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('PulsatingHighlighter')
export class PulsatingHighlighter extends Component {
@property(Material)
redMaterial: Material = null!;
private _originalMaterials: Material[] = [];
private _currentAlpha = 0;
private _direction = 1;
private _animationSpeed = 3; // Скорость изменения альфа-канала
onLoad() {
this._storeOriginalMaterials();
}
private _storeOriginalMaterials() {
const renderer = this.node.getComponent(MeshRenderer);
if (!renderer) return;
this._originalMaterials = renderer.materials
.filter((m): m is Material => !!m)
.map(m => {
const newMat = new Material();
newMat.copy(m);
return newMat;
});
}
public switchToRed() {
const renderer = this.node.getComponent(MeshRenderer);
if (!renderer || !this.redMaterial) return;
// Создаем и настраиваем материал
const redMat = new Material();
redMat.copy(this.redMaterial);
redMat.initialize({
effectName: 'builtin-unlit',
defines: { USE_TRANSPARENT: true }
});
redMat.setProperty('mainColor', new Color(255, 0, 0, 0));
renderer.materials = renderer.materials.map(() => redMat);
// Запускаем анимацию
this._currentAlpha = 0;
this._direction = 1;
this.schedule(this._updateAlpha, 0.016);
// Возвращаем оригинал через 3 секунды
this.scheduleOnce(() => {
this._restoreOriginalMaterials();
this.unschedule(this._updateAlpha);
}, 10);
}
private _updateAlpha() {
this._currentAlpha += this._direction * this._animationSpeed;
// Ограничиваем значение между 0 и 255
this._currentAlpha = math.clamp(this._currentAlpha, 0, 255);
// Меняем направление
if (this._currentAlpha === 255 || this._currentAlpha === 0) {
this._direction *= -1;
}
const renderer = this.node.getComponent(MeshRenderer);
if (renderer) {
renderer.materials.forEach(mat => {
const color = mat?.getProperty('mainColor') as Color;
color.a = this._currentAlpha;
mat?.setProperty('mainColor', color);
});
}
}
private _restoreOriginalMaterials() {
const renderer = this.node.getComponent(MeshRenderer);
if (!renderer) return;
renderer.materials = this._originalMaterials.map(m => {
const mat = new Material();
mat.copy(m);
return mat;
});
}
onDestroy() {
this.unscheduleAllCallbacks();
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "04b2bc74-c164-4535-9503-ce338ab92ee9",
"files": [],
"subMetas": {},
"userData": {}
}

7
package.json Executable file
View File

@ -0,0 +1,7 @@
{
"name": "Yantar",
"uuid": "232a1eb0-be7e-44c1-9a40-0b7b547fca46",
"creator": {
"version": "3.8.5"
}
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.3.9"
}

View File

@ -0,0 +1,23 @@
{
"__version__": "3.0.8",
"game": {
"name": "UNKNOW GAME",
"app_id": "UNKNOW",
"c_id": "0"
},
"appConfigMaps": [
{
"app_id": "UNKNOW",
"config_id": "df66a2"
}
],
"configs": [
{
"app_id": "UNKNOW",
"config_id": "df66a2",
"config_name": "Default",
"config_remarks": "",
"services": []
}
]
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.0.1"
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.0.10"
}

View File

@ -0,0 +1,23 @@
{
"__version__": "1.0.1",
"information": {
"customSplash": {
"id": "customSplash",
"label": "customSplash",
"enable": false,
"customSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?"
}
},
"removeSplash": {
"id": "removeSplash",
"label": "removeSplash",
"enable": false,
"removeSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?"
}
}
}
}

View File

@ -0,0 +1,3 @@
{
"__version__": "1.0.4"
}

View File

@ -0,0 +1,11 @@
{
"general": {
"highQuality": true
},
"__version__": "1.0.6",
"fbx": {
"legacyFbxImporter": {
"visible": true
}
}
}

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
/* Base configuration. Do not edit this field. */
"extends": "./temp/tsconfig.cocos.json",
/* Add your custom configuration here. */
"compilerOptions": {
"strict": true
}
}