File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
docs/user-manual/web-components
i18n/ja/docusaurus-plugin-content-docs/current/user-manual/web-components Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ Scripts add custom behaviors to entities in your PlayCanvas Web Components app.
8
8
Let's consider a simple script that rotates an entity over time:
9
9
10
10
``` javascript title="rotate-script.mjs"
11
- export default class RotateScript {
11
+ import { Script } from ' playcanvas' ;
12
+
13
+ export class RotateScript extends Script {
12
14
static scriptName = ' rotateScript' ;
13
15
14
16
update (dt ) {
@@ -49,8 +51,10 @@ Our rotate script is currently hardcoded to rotate at 90 degrees per second. But
49
51
50
52
Let's update our script to accept a rotation speed as an attribute:
51
53
52
- ``` javascript title="rotate-script.mjs" {4-8,12}
53
- export default class RotateScript {
54
+ ``` javascript title="rotate-script.mjs" {6-10,14}
55
+ import { Script } from ' playcanvas' ;
56
+
57
+ export class RotateScript extends Script {
54
58
static scriptName = ' rotateScript' ;
55
59
56
60
/**
Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ sidebar_position: 3
8
8
エンティティを時間とともに回転させるシンプルなスクリプトを考えてみましょう。
9
9
10
10
``` javascript title="rotate-script.mjs"
11
- export default class RotateScript {
11
+ import { Script } from ' playcanvas' ;
12
+
13
+ export class RotateScript extends Script {
12
14
static scriptName = ' rotateScript' ;
13
15
14
16
update (dt ) {
@@ -49,8 +51,10 @@ export default class RotateScript {
49
51
50
52
回転速度を属性として受け入れるようにスクリプトを更新しましょう。
51
53
52
- ``` javascript title="rotate-script.mjs" {4-8,12}
53
- export default class RotateScript {
54
+ ``` javascript title="rotate-script.mjs" {6-10,14}
55
+ import { Script } from ' playcanvas' ;
56
+
57
+ export class RotateScript extends Script {
54
58
static scriptName = ' rotateScript' ;
55
59
56
60
/**
You can’t perform that action at this time.
0 commit comments