本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス · 再現できる2D物理

Rig型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A set of nodes and links, with the fixed shapes the round nodes rest on.

インポート

import type { Rig } from "@johnmorrisdotca/karakuri/physics";

定義

interface Rig {
    nodes: RigNode[];
    links: RigLink[];
    statics: WorldShape[];
    gravity: number;
    damping: number;
    iterations: number;
    grip: number;
    bounce: number;
}

メンバー

名前型説明
nodesRigNode[]
linksRigLink[]
staticsWorldShape[]
gravitynumber
dampingnumber

How much of its speed a node keeps each step (1 keeps all).

iterationsnumber
gripnumber

How much of a round node's speed along a surface it keeps when it touches one.

bouncenumber

例

import { addRope, createRig } from "@johnmorrisdotca/karakuri/physics";
import type { Rig } from "@johnmorrisdotca/karakuri/physics";

const rig=createRig({gravity:0,iterations:1});
addRope(rig,0,0,10,0,2);
const value: Rig = rig;
console.log(value);
{
  nodes: [
    { x: 0, y: 0, px: 0, py: 0, invMass: 0, r: 0 },
    { x: 5, y: 0, px: 5, py: 0, invMass: 1, r: 0 },
    { x: 10, y: 0, px: 10, py: 0, invMass: 1, r: 0 }
  ],
  links: [
    { a: 0, b: 1, length: 5, alive: true },
    { a: 1, b: 2, length: 5, alive: true }
  ],
  statics: [],
  gravity: 0,
  damping: 0.999,
  iterations: 1,
  grip: 0.9,
  bounce: 0.25
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。